Reputation: 3687
I am using chrome.identity API and i want to know if i can use that access token for Google drive operations. Currently I am using the drive API, and i am getting the tokens through code exchange, and i want to know if i can hook the new flow in the existing one (this requires to have the refresh token also).
For example : 1) current implementation: - create service - exchange code and obtain accessToken and refreshToken - do Drive op's
2) new code: - get the accessToken with chrome.identity.getAccessToken - obtain the refreshToken - do Drive op's (same as the old flow)
Upvotes: 1
Views: 231
Reputation: 2987
You can't obtain refreshToken from accessToken. You obtain accessToken from refreshToken.
What you should do is in APIs console, on the left, choose "services" and select all applications you want to authorize. You can choose Drive API and any other APIs you need to use then this one key will authorize for all services of your choice.
Then, in order to obtain refreshToken, in OAuth2 options, add access_type=offline then you will retrieve refreshToken alongside with your accessToken. Whenever accessToken expires, you can refresh using refreshToken to obtain new accessToken.
Upvotes: 1