Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding scopes in google auth doesn't work #7116

Closed
thearunraja opened this issue Mar 30, 2023 · 1 comment
Closed

Adding scopes in google auth doesn't work #7116

thearunraja opened this issue Mar 30, 2023 · 1 comment
Labels
question Ask how to do something or how something works

Comments

@thearunraja
Copy link

Question 馃挰

I'm trying to integrate google classroom in my nextjs app. So, I need to add the scopes for that in google provider. If I do that, it's not working or adding scopes when I log in.

When I console scopes granted for access token, it only returns user scopes. Not the scopes I added for google classroom

Here's the code for [...nextauth].js

`import NextAuth from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';

const scopes = [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/classroom.courses.readonly',
'https://www.googleapis.com/auth/classroom.coursework.students.readonly',
'https://www.googleapis.com/auth/classroom.coursework.me.readonly',
'https://www.googleapis.com/auth/classroom.coursework.me',
'https://www.googleapis.com/auth/classroom.coursework.students',
];

export const authOptions = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
scope: scopes.join(' '),
authorization: {
params: {
prompt: 'consent',
access_type: 'offline',
response_type: 'code',
},
},
}),
],
callbacks: {
async jwt({ token, account, profile }) {
if (account) {
token.accessToken = account.access_token;
token.refreshToken = account.refresh_token;
token.id = profile.id;
}
return token;
},
async session(session, token) {
return session;
},
},
};

export default NextAuth(authOptions);
`

How to reproduce 鈽曪笍

Contributing 馃檶馃徑

Yes, I am willing to help answer this question in a PR

@thearunraja thearunraja added the question Ask how to do something or how something works label Mar 30, 2023
@josephkiwan
Copy link

@thearunraja how did you solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Ask how to do something or how something works
Projects
None yet
Development

No branches or pull requests

2 participants