Social login
Add Battle.net sign-in to a Next.js Auth.js application.
Auth.js · Const
BattleNet is Auth.js’s built-in Battle.net OAuth 2 provider. Configure it with a client ID, client secret, and a supported regional issuer.
BattleNet configures Auth.js to authenticate users through Battle.net's OAuth 2 service. Supply the client credentials and choose a supported regional issuer; Auth.js then uses the provider's built-in endpoints and maps the callback to the Battle.net provider route.
BattleNet(options)| Name | Type | Description |
|---|---|---|
options | OAuthUserConfig<P> & { issuer: BattleNetIssuer; } | OAuth provider configuration plus a required supported Battle.net issuer. |
A configured Battle.net OAuth provider definition for Auth.js.
import NextAuth from "next-auth"
import BattleNet from "next-auth/providers/battlenet"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [BattleNet({
clientId: process.env.AUTH_BATTLENET_ID!,
clientSecret: process.env.AUTH_BATTLENET_SECRET!,
issuer: process.env.AUTH_BATTLENET_ISSUER as
"https://oauth.battle.net",
})],
})Register the Battle.net provider with credentials and an issuer for the target region.
Add Battle.net sign-in to a Next.js Auth.js application.
Route users through the Battle.net OAuth endpoint matching their region.
Adjust the built-in OAuth settings for an atypical deployment.
Use BattleNet from the framework-specific provider package, then pass it in the NextAuth providers array. Configure the client ID, client secret, and a supported issuer.
Follow-up: What determines the issuer value? It selects the Battle.net OAuth endpoint for the application's region, so it must match one of the documented regional URLs.
The provider callback for the Next.js integration is /api/auth/callback/battlenet, and the full URL uses the application's origin. That URL must be configured with the provider.
Follow-up: What would you check if the callback fails? Verify the deployment origin and ensure the registered callback URL exactly matches the generated route.
BattleNet is an OAuth 2 provider with a built-in default configuration. Supplying options overrides or completes that configuration for the application.
Follow-up: How could the defaults be changed beyond these options? Use Auth.js's documented customization approach for a built-in OAuth provider.
BattleNetProfileBattleNetIssuerOAuthUserConfigAuthproviders