Add Box sign-in
Users authenticate through Box in a Next.js application.
Auth.js · Const
Box is a built-in Auth.js OAuth provider. Configure it with Box credentials and add it to the providers array; in Next.js, register the /api/auth/callback/box callback URL.
Box is a built-in OAuth 2.0 provider for Auth.js. Add the provider to the authentication configuration, provide its client credentials through the documented environment variables, and register the generated callback URL with Box.
Box(options): OAuthConfig<Record<string, any>>| Name | Type | Description |
|---|---|---|
options | OAuthUserConfig<Record<string, any>> | Optional provider configuration, including OAuth client settings and other overrides. |
OAuthConfig<Record<string, any>>
/api/auth/callback/box callback endpoint with the Box application.import NextAuth from "next-auth"
import Box from "next-auth/providers/box"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [Box],
})Registers the built-in Box provider in a Next.js Auth.js configuration.
Users authenticate through Box in a Next.js application.
An application already uses Auth.js's provider list.
A Box integration needs non-default OAuth settings.
Box is enabled by importing the provider from the framework-specific Auth.js package and placing it in the providers array. In Next.js, the documented form is providers: [Box].
Follow-up: How would you supply credentials? Use the documented AUTH_BOX_CLIENT_ID and AUTH_BOX_CLIENT_SECRET environment variables, or pass provider options when customization is needed.
The callback URL is https://example.com/api/auth/callback/box for the Next.js integration. That URL must be configured in the Box application settings.
Follow-up: What changes for another supported framework? Use that framework's callback path shown in the provider documentation, such as /auth/callback/box.
The provider has a default configuration and returns an OAuth configuration when invoked with provider options. Its documented function signature accepts an OAuthUserConfig<Record<string, any>> object.
Follow-up: Why might the default be overridden? To change supported OAuth settings for a particular integration, while retaining the built-in provider behavior.
OAuthConfigOAuthUserConfigcustomizing a built-in OAuth providerBox OAuth documentation