How to generate access token using refresh token through google drive API?

前端 未结 8 1370
一个人的身影
一个人的身影 2020-12-04 14:33

I have completed steps of authorization and obtained access token and refresh token.

What should I do next to generate access token using refresh token that I have s

8条回答
  •  时光说笑
    2020-12-04 14:44

    It's an old question but seems to me it wasn't completely answered, and I needed this information too so I'll post my answer.

    If you want to use the Google Api Client Library, then you just need to have an access token that includes the refresh token in it, and then - even though the access token will expire after an hour - the library will refresh the token for you automatically.

    In order to get an access token with a refresh token, you just need to ask for the offline access type (for example in PHP: $client->setAccessType("offline");) and you will get it. Just keep in mind you will get the access token with the refresh token only in the first authorization, so make sure to save that access token in the first time, and you will be able to use it anytime.

    Hope that helps anyone :-)

提交回复
热议问题