简体   繁体   English

如何获取Google网站管理员api(Node.js)的访问令牌

[英]How to get access token for google webmasters api (Node.js)

i need access token for submitting sitemap. 我需要访问令牌才能提交站点地图。 i use passport like so 我像这样使用护照

passport.authenticate('googleApi', {scope: ['profile', 'https://www.googleapis.com/auth/webmasters']});

and get 并得到

{ code: '4/aEzOOw1j-1rNCXCVajylMVRasdo2Kasdreisasdradk.MijA9hPKsg8WYFZr95uasdUzab8UkwI' }

in request.query 在request.query中

but this token is invalid according to 但是根据

https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=MY_TOKEN

thanks in advance. 提前致谢。

The code you have got is authorization code. 您获得的代码是授权代码。 You have to get access token by exchanging this authorization code. 您必须通过交换此授权码来获取访问令牌。 Read about oauth 2.0 authentication 了解有关oauth 2.0身份验证的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM