How to get dummy google access token to test oauth google api

前端 未结 4 1186
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 01:20

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

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

4条回答
  •  悲哀的现实
    2020-12-29 02:16

    Use the Google OAuth playground:

    Request:

    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
    

    (Successful) Response:

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

    I also highly recommend reading the Google OAuth 2.0 documentation

提交回复
热议问题