How to get access token using gmail api

前端 未结 7 1009
遇见更好的自我
遇见更好的自我 2021-01-01 22:29

I got the authorization code following this document. But when I tried to get access token, I always got errors. Can anyone help me ?

public String AccessTok         


        
相关标签:
7条回答
  • 2021-01-01 23:23

    You are not using the right endpoint. Try to change the authURL to https://www.googleapis.com/oauth2/v4/token

    From the documentation:

    To make this token request, send an HTTP POST request to the /oauth2/v4/token endpoint

    The actual request might look like the following:

    POST /oauth2/v4/token HTTP/1.1
    Host: www.googleapis.com
    Content-Type: application/x-www-form-urlencoded
    
    code=4/v6xr77ewYqhvHSyW6UJ1w7jKwAzu&
    client_id=8819981768.apps.googleusercontent.com&
    client_secret=your_client_secret&
    redirect_uri=https://oauth2-login-demo.appspot.com/code&
    grant_type=authorization_code
    

    Reference https://developers.google.com/identity/protocols/OAuth2InstalledApp#handlingtheresponse

    0 讨论(0)
提交回复
热议问题