Azure Provider
If you need a detailed guide on how to setup a provider pleaser refer to the Getting Started and Making your first integration guides.
Resources
- Microsoft identity platform and OAuth 2.0 authorization code flow (opens in a new tab)
- Scopes (opens in a new tab)
Setup
Callback URL
https://your-app.com/api/auth/integration/azureEnvironment variables
.env.local
AUTH_AZURE_ID=your-client-id
AUTH_AZURE_SECRET=your-client-secretAdd the provider to the auth.ts file.
auth.ts
import { NextIntegrate } from 'next-integrate';
export const { auth } = NextIntegrate({
// The URL of the app, e.g. https://example.com, set in the .env file.
// If you want to modify the redirect URL, to be prefixed with something else,
// you can do it here like this:
// base_url: process.env.BASE_URL! + "/some-prefix",
// This will change the redirect URL to eg. https://example.com/some-prefix/api/auth/integration/google
base_url: process.env.BASE_URL!,
providers: [
{
provider: 'azure',
client_id: process.env.AUTH_AZURE_ID!,
client_secret: process.env.AUTH_AZURE_SECRET!,
integrations: [],
},
],
});Add an integration
auth.ts
import { NextIntegrate } from 'next-integrate';
export const { auth } = NextIntegrate({
// The URL of the app, e.g. https://example.com, set in the .env file.
// If you want to modify the redirect URL, to be prefixed with something else,
// you can do it here like this:
// base_url: process.env.BASE_URL! + "/some-prefix",
// This will change the redirect URL to eg. https://example.com/some-prefix/api/auth/integration/google
base_url: process.env.BASE_URL!,
providers: [
{
provider: 'azure',
client_id: process.env.AUTH_AZURE_ID!,
client_secret: process.env.AUTH_AZURE_SECRET!,
integrations: [
{
name: 'some_custom_name',
options: {
scope: 'openid User.Read',
},
callback: async (data) => {
// This is where you can save the data to a database, or do something else with it.
},
},
],
},
],
});Usage
To use the your new integration, you can use the <Integrate /> component found in the Getting Started Guide.
import Integrate from '@/components/integrate';
export default function Home() {
return (
<main>
<Integrate provider="azure" name="some_custom_name">
Get Azure User Info
</Integrate>
</main>
);
}Options
You can pass various parameters on the options object to customize the integration. The parameters are specific to the Azure provider, please refer to the documentation (opens in a new tab), to verify the information if needed.
| parameter | type | required | description |
|---|---|---|---|
scope | string | true | A list of URL's that determines what the user will be prompted to give access to. You can parse multiple scopes by seperating with a space. You can find the full list of scopes for the here (opens in a new tab). |
response_mode | string | recommended | Specifies how the identity platform should return the requested token to your app. Valid values are query, fragment, and form_post. |
prompt | string | optional | Indicates the type of user interaction that is required. Valid values are login, none, consent, and select_account. |
login_hint | string | optional | You can use this parameter to pre-fill the username and email address field of the sign-in page for the user. Apps can use this parameter during reauthentication, after already extracting the login_hint optional claim from an earlier sign-in. |
domain_hint | string | optional | If included, the app skips the email-based discovery process that user goes through on the sign-in page, leading to a slightly more streamlined user experience. For example, sending them to their federated identity provider. Apps can use this parameter during reauthentication, by extracting the tid from a previous sign-in. |