providers/azure-ad
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 developmenthttp://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.
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.
The Minecraft provider comes with a default configuration. To override the defaults for your use case, check out customizing a built-in OAuth provider.
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.