3
votes

I get an oauth2 access token using the following scopes from the user.

scope: ["https://www.googleapis.com/auth/youtube"]

Then i proceed to use this token for calls to the youtube v3 api. These calls work at first but then I start getting this response/error.

{ errors: [
  {
    domain: 'global',
    reason: 'authError',
    message: 'Invalid Credentials',
    locationType: 'header',
    location: 'Authorization'
  }],
  code: 401,
  message: 'Invalid Credentials'
}

Is anyone else experiencing this intermitten errors? Is there a way to debug the oauth token like facebook tool? Token seems to expire in 1 hour. Get refresh token google api

example url

https://www.googleapis.com/youtube/v3/channels/?part=id,snippet,contentDetails,statistics,topicDetails&mine=true&access_token={access_token}

1
Ok it appears that the token is expiring in a hour. How can i get a longer token life?dre
tracked this url down. googleapis.com/oauth2/v1/tokeninfo?access_token={access_token}}dre
I am facing same problem.Ritesh Gune

1 Answers

9
votes

Token was expired. Had to use approval_prompt=force,access_type=offline. When requesting the access_token, this always gets a new refresh token. Then I used this refresh token to get a new token every time I needed to access the api on the user's behalf.

Useful tool for debugging google access token problems:

https://www.googleapis.com/oauth2/v1/tokeninfo?access_token={access_token}