尝试使用Google API的REST调用(而不是通过JavaScript或任何其他编码语言)创建自动化博客帖子。我能够创建所有的谷歌使用api密钥和Auth2.0客户端。https://console.cloud.google.com/apis/credentials APi and auth2因为博客的GET调用与API一起工作,所以我能够执行所有的get活动
要使用接口发布博客(插入:https://developers.google.com/blogger/docs/3.0/using#AddingAPost),需要使用访问令牌进行身份验证。若要获取用于身份验证的访问令牌,请参考https://developers.google.com/identity/protocols/oauth2/javascript-implicit-flow#oauth-2.0-endpoints。正在获取200 Ok,但未获取访问令牌。
发布https://accounts.google.com/o/oauth2/v2/auth
发布数据: client_id=.apps.googleusercontent.com&response_type=token&redirect_uri=http://localhost:8080&scope=https://www.googleapis.com/auth/blogger
发布于 2021-07-12 16:24:07
首先,它不适用于api密钥,因为api密钥只给你访问公共数据的权限,私人用户数据需要授权。使用Oauth2为您获取访问令牌。
要获取访问令牌,您需要一些东西
第一个是创建同意屏幕的链接
https://accounts.google.com/o/oauth2/auth?client_id={clientid}.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/analytics.readonly&response_type=code
然后您需要交换授权码
https://accounts.google.com/o/oauth2/token
code=4/X9lG6uWd8-MMJPElWggHZRzyFKtp.QubAT_P-GEwePvB8fYmgkJzntDnaiAI&client_id={ClientId}.apps.googleusercontent.com&client_secret={ClientSecret}&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code
该调用将为您提供访问令牌。
我不太清楚你在做什么,但我有一篇博客文章展示了它是如何工作的,如果你只是想知道如何设置PostMan以使用Google 3 Legged OAuth2 Flow Oauth2授权,我有一段视频向你展示如何设置它如果你真的想了解它是如何工作的我有一段视频将带你使用CURL Understanding Google OAuth 2.0 with curl完成它
https://stackoverflow.com/questions/68344303
复制相似问题