NextAuth login with Youtube scopes

I've been trying to use nextauth to have the user consent to some scopes for the youtube Data API v3. Everything works fine but Google returns error.
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
authorization: {
params: {
prompt: "consent",
access_type: "offline",
response_type: "code",
scope:
"openid https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/youtubepartner",

},
},
}),
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
authorization: {
params: {
prompt: "consent",
access_type: "offline",
response_type: "code",
scope:
"openid https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/youtubepartner",

},
},
}),
These are my provider options. However, I have 2 problems. 1. If I don't include openid it won't let login, and since in the docs it is written I assume it has to be 2. If I do set openid it throws CORS origin error My question is, did anyone do something similar and how could I solve this? And how do you set headers in NextAuth with GoogleProvider and prisma adapter? Because I think the latter would also solve this issue. Or even how I could debug this, because setting debu: true doesn't provide any useful info...
1 Reply
JulieCezar
JulieCezar2y ago
Solved this like so:
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
authorization: {
params: {
prompt: "consent",
access_type: "offline",
response_type: "code",
scope:
"openid email profile https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/youtubepartner",

},
},
}),
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
authorization: {
params: {
prompt: "consent",
access_type: "offline",
response_type: "code",
scope:
"openid email profile https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.readonly https://www.googleapis.com/auth/youtubepartner",

},
},
}),
Found in the GoogleProvider schema that the default scope was openid email profile.
Want results from more Discord servers?
Add your server