in packages/better-auth/src/plugins/generic-oauth/index.ts [329:396]
signInWithOAuth2: createAuthEndpoint(
"/sign-in/oauth2",
{
method: "POST",
body: z.object({
providerId: z.string({
description: "The provider ID for the OAuth provider",
}),
callbackURL: z
.string({
description: "The URL to redirect to after sign in",
})
.optional(),
errorCallbackURL: z
.string({
description: "The URL to redirect to if an error occurs",
})
.optional(),
newUserCallbackURL: z
.string({
description:
"The URL to redirect to after login if the user is new",
})
.optional(),
disableRedirect: z
.boolean({
description: "Disable redirect",
})
.optional(),
scopes: z
.array(z.string(), {
message:
"Scopes to be passed to the provider authorization request.",
})
.optional(),
requestSignUp: z
.boolean({
description:
"Explicitly request sign-up. Useful when disableImplicitSignUp is true for this provider",
})
.optional(),
}),
metadata: {
openapi: {
description: "Sign in with OAuth2",
responses: {
200: {
description: "Sign in with OAuth2",
content: {
"application/json": {
schema: {
type: "object",
properties: {
url: {
type: "string",
},
redirect: {
type: "boolean",
},
},
},
},
},
},
},
},
},
},