且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取虚拟谷歌访问令牌来测试 oauth google api

更新时间:2023-02-16 08:29:31

使用 Google OAuth 游乐场:

请求:

POST /oauth2/v3/token HTTP/1.1
Host: www.googleapis.com
Content-Type: application/x-www-form-urlencoded

code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7&
client_id=8819981768.apps.googleusercontent.com&
client_secret={client_secret}&
redirect_uri=https://oauth2-login-demo.appspot.com/code&
grant_type=authorization_code

(成功)响应:

{
  "access_token":"1/fFAGRNJru1FTz70BzhT3Zg",
  "expires_in":3920,
  "token_type":"Bearer"
}

我还强烈建议您阅读 Google OAuth 2.0 文档