atinux / nuxt-auth-utils

Add Authentication to Nuxt applications with secured & sealed cookies sessions.
MIT License
976 stars 91 forks source link

Add more scopes on the google oath #64

Closed prpanto closed 8 months ago

prpanto commented 8 months ago

Im try to use the youtube service and i try to add the some more scopes like youtube.readonly, etc... When I did this I have an invalid_scope error. Do you have any solution or something to advice?

Some requested scopes were invalid. {valid=[https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile], invalid=[youtube.readonly]} 
monkemedia commented 8 months ago

To fix this, go to server/routes/auth/auth0.get.ts and you can add your scopes there:

export default oauth.auth0EventHandler({
  config: {
    emailRequired: true,
    scope: ['email', 'profile', 'openid'] // USE AN ARRAY FOR YOUR SCOPES
  },
  async onSuccess(event, res) {
    console.log('res', res)
    return sendRedirect(event, '/')
  }
})

Hope this helps

prpanto commented 8 months ago

Thanks for reply @monkemedia The solution for this was to add all the auth url path like:

scope: [
      'email',
      'profile',
      'https://www.googleapis.com/auth/youtube',
      'https://www.googleapis.com/auth/youtubepartner',
      'https://www.googleapis.com/auth/youtube.readonly',
      'https://www.googleapis.com/auth/youtube.force-ssl',
      'https://www.googleapis.com/auth/youtubepartner-channel-audit',
      'https://www.googleapis.com/auth/youtube.third-party-link.creator',
      'https://www.googleapis.com/auth/youtube.channel-memberships.creator',
    ],