How to get access token using gmail api

前端 未结 7 1025
遇见更好的自我
遇见更好的自我 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:02

    Firstly, you must look this page :

    https://developers.google.com/gmail/api/auth/web-server#create_a_client_id_and_client_secret

    The value you see in the query parameter code is a string you have to post to google in order to get the access token.

    After the web server receives the authorization code, it may exchange the authorization code for an access token and a refresh token. This request is an HTTPS POST to the URL https://www.googleapis.com/oauth2/v3/token POST /oauth2/v3/token HTTP/1.1 content-type: application/x-www-form-urlencoded

    code=4/v4-CqVXkhiTkn9uapv6V0iqUmelHNnbLRr1EbErzkQw#&redirect_uri=&client_id=&scope=&client_secret=************&grant_type=authorization_code https://developers.google.com/identity/protocols/OAuth2WebServer

提交回复
热议问题