Skip to main content

providers/azure-ad

Built-in Minecraft integration.

default()​

default<P>(options): OAuthConfig< P >

Add Minecraft login to your page.

Setup​

Callback URL​

https://example.com/api/auth/callback/minecraft

Configuration​

import Auth from "@auth/core"
import Minecraft from "@auth/core/providers/minecraft"

const request = new Request(origin)
const response = await Auth(request, {
providers: [Minecraft({ clientId: AZURE_AD_CLIENT_ID, clientSecret: AZURE_AD_CLIENT_SECRET })],
})

Resources​

Type parameters​

β–ͺ P extends MinecraftProfile

Parameters​

β–ͺ options: OAuthUserConfig< P > & { tenantId: string; }

Returns​

OAuthConfig< P >

Example​

  • In https://portal.azure.com/ search for "Azure Active Directory", and select your organization.
  • Next, go to "App Registration" in the left menu, and create a new one.
  • Pay close attention to "Who can use this application or access this API?"
    • This allows you to scope access to specific types of user accounts
    • Select "Personal Microsoft accounts only".
  • When asked for a redirection URL, use https://yourapplication.com/api/auth/callback/minecraft or for development http://localhost:3000/api/auth/callback/minecraft.
  • After your App Registration is created, under "Client Credential" create your Client secret.
  • Now copy your:
    • Application (client) ID
    • Client secret (value)

In .env.local create the following entries:

AZURE_AD_CLIENT_ID=<copy Application (client) ID here>
AZURE_AD_CLIENT_SECRET=<copy generated client secret value here>

That will default the tenant to use the consumers authorization endpoint. For more details see here.

note

Minecraft only supports the consumers tenant.

In pages/api/auth/[...nextauth].js find or add the Minecraft entries:

import Minecraft from "next-auth/providers/minecraft";

...
providers: [
Minecraft({
clientId: process.env.AZURE_AD_CLIENT_ID,
clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
}),
]
...

Notes​

By default, Auth.js assumes that the Minecraft provider is based on the OAuth 2 specification.

tip

The Minecraft provider comes with a default configuration. To override the defaults for your use case, check out customizing a built-in OAuth provider.

Disclaimer

If you think you found a bug in the default configuration, you can open an issue.

Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec, we might not pursue a resolution. You can ask for more help in Discussions.