如何获取虚拟Google访问令牌以测试OAuth Google API

问题描述:

有什么方法可以生成访问令牌以测试用于通过gmail登录的oauth?

Is there any way in which I can generate access token to test oauth for logging in with gmail?

我创建了一个Google应用,并获取了客户端和秘密ID.

I have created a google app, and got the client and secret ids.

我知道facebook会允许您从此URL https://developers.facebook.com执行此操作/tools/accesstoken/

I know facebook will allow you to do so from this url https://developers.facebook.com/tools/accesstoken/

Google是否有这种方法?

Is there any method like this for Google?

使用 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文档