Skip to content

Oauth2 client does NOT work with specified scope #3361

@csethanhcong

Description

@csethanhcong

- What you're trying to do

  • I completed an Oauth2 flow to get the user's consent and stored the refresh token
  • In the flow, I ask for sensitive scope (let's say youtube.channel-owner)
  • I made another API call under this refresh token permission and scope but got an error: 'Access forbidden. The request may not be properly authorized.'

- What code you've already tried

// Init auth client snippet
const oauth2Client = new google.auth.OAuth2(
  CLIENT_ID,
  CLIENT_SECRET
);

const _credentials: Credentials = {};
_credentials.refresh_token = refreshToken;
if (!!accessToken) {
  _credentials.access_token = accessToken;
}
  _credentials.scope = 'https://www.googleapis.com/auth/youtube.channel-memberships.creator';
oauth2Client.setCredentials(_credentials);
...
// API call
const resp = await google.youtube('v3').members.list({
    part: ['snippet'],
    filterByMemberChannelId: userChannelId,
    auth: oauth2Client,
  });

- Any error messages you're getting
'Access forbidden. The request may not be properly authorized.'

Could someone please help me with this? Thanks in advance.

Metadata

Metadata

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions