Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 stored through google drive API?

I won't be able to use any sdk since I am working on Force.com so please suggest the way to implement it directly through the API.

like image 580
Niranja Avatar asked May 17 '12 06:05

Niranja


People also ask

How do I get the access token from refresh token?

Because OAuth2 access expires after a limited time, an OAuth2 refresh token is used to automatically renew OAuth2 access. Click the tab for the programming language you're using, and follow the instructions to generate an OAuth2 refresh token and set up the configuration file for your client.

Can refresh token be used as access token?

A refresh token can help you balance security with usability. Since refresh tokens are typically longer-lived, you can use them to request new access tokens after the shorter-lived access tokens expire.


1 Answers

If you are using web api then you should make a http POST call to URL : https://www.googleapis.com/oauth2/v4/token with following request body

client_id: <YOUR_CLIENT_ID> client_secret: <YOUR_CLIENT_SECRET> refresh_token: <REFRESH_TOKEN_FOR_THE_USER> grant_type: refresh_token 

refresh token never expires so you can use it any number of times. The response will be a JSON like this:

{   "access_token": "your refreshed access token",   "expires_in": 3599,   "scope": "Set of scope which you have given",   "token_type": "Bearer" } 
like image 146
Ashutosh Singh Avatar answered Oct 20 '22 01:10

Ashutosh Singh