Google Oauth Scopes Error

src/lib/auth.ts
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from "./prisma";

export const auth = betterAuth({
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
// Request scopes needed for Google Docs reading:
scope: "openid email profile https://www.googleapis.com/auth/documents.readonly https://www.googleapis.com/auth/drive.metadata.readonly",
},
},
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
user: {
additionalFields: {
education: { type: "string", required: false },
school: { type: "string", required: false },
onboardingCompleted: {
type: "boolean",
required: false,
defaultValue: false,
},
},
},
});
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from "./prisma";

export const auth = betterAuth({
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
// Request scopes needed for Google Docs reading:
scope: "openid email profile https://www.googleapis.com/auth/documents.readonly https://www.googleapis.com/auth/drive.metadata.readonly",
},
},
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
user: {
additionalFields: {
education: { type: "string", required: false },
school: { type: "string", required: false },
onboardingCompleted: {
type: "boolean",
required: false,
defaultValue: false,
},
},
},
});
Error:
Some requested scopes were invalid. {valid=[https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile, openid], invalid=[a, c, d, e, f, g, h, i, l, m, n, ., o, /, p, r, s, t, u, v, w, y, :]} Learn more about this error
If you are a developer of SparkStudy, see error details.
Error 400: invalid_scope
Some requested scopes were invalid. {valid=[https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile, openid], invalid=[a, c, d, e, f, g, h, i, l, m, n, ., o, /, p, r, s, t, u, v, w, y, :]} Learn more about this error
If you are a developer of SparkStudy, see error details.
Error 400: invalid_scope
Error 400: invalid_scope
Request details: flowName=GeneralOAuthFlow
Error 400: invalid_scope
Request details: flowName=GeneralOAuthFlow
This was working before adding the https://www.googleapis.com/auth/documents.readonly and https://www.googleapis.com/auth/drive.metadata.readonly scopes
No description
Solution:
you should pass scopes as an array of string instead
Jump to solution
3 Replies
Devium
DeviumOP4w ago
@bekacru do you know what the issue could be?
Solution
bekacru
bekacru4w ago
you should pass scopes as an array of string instead
Devium
DeviumOP4w ago
thank you!

Did you find this page helpful?