{
providerId: 'outlookEmail',
clientId: process.env.MICROSOFT_CLIENT_ID!,
clientSecret: process.env.MICROSOFT_CLIENT_SECRET_VALUE!,
authorizationUrl:
'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
tokenUrl:
'https://login.microsoftonline.com/common/oauth2/v2.0/token',
userInfoUrl:
'https://graph.microsoft.com/v1.0/me?$select=id,displayName,mail,userPrincipalName',
scopes: [
'openid',
'email',
'profile',
'offline_access',
'User.Read',
'Mail.ReadWrite',
'Mail.Send',
],
pkce: true,
disableSignUp: true,
getUserInfo: async (tokens) => {
const res = await fetch(
'https://graph.microsoft.com/v1.0/me?$select=id,displayName,mail,userPrincipalName',
{
headers: { Authorization: `Bearer ${tokens.accessToken}` },
}
);
if (!res.ok) return null;
const me: {
id: string;
displayName?: string | null;
mail?: string | null;
userPrincipalName?: string | null;
} = await res.json();
const email = me.mail ?? me.userPrincipalName ?? null;
const name = me.displayName ?? email ?? 'Microsoft User';
return {
id: me.id,
email,
name,
image: undefined,
emailVerified: true,
};
},
},
{
providerId: 'outlookEmail',
clientId: process.env.MICROSOFT_CLIENT_ID!,
clientSecret: process.env.MICROSOFT_CLIENT_SECRET_VALUE!,
authorizationUrl:
'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
tokenUrl:
'https://login.microsoftonline.com/common/oauth2/v2.0/token',
userInfoUrl:
'https://graph.microsoft.com/v1.0/me?$select=id,displayName,mail,userPrincipalName',
scopes: [
'openid',
'email',
'profile',
'offline_access',
'User.Read',
'Mail.ReadWrite',
'Mail.Send',
],
pkce: true,
disableSignUp: true,
getUserInfo: async (tokens) => {
const res = await fetch(
'https://graph.microsoft.com/v1.0/me?$select=id,displayName,mail,userPrincipalName',
{
headers: { Authorization: `Bearer ${tokens.accessToken}` },
}
);
if (!res.ok) return null;
const me: {
id: string;
displayName?: string | null;
mail?: string | null;
userPrincipalName?: string | null;
} = await res.json();
const email = me.mail ?? me.userPrincipalName ?? null;
const name = me.displayName ?? email ?? 'Microsoft User';
return {
id: me.id,
email,
name,
image: undefined,
emailVerified: true,
};
},
},