Skip to content

Commit

Permalink
Merge pull request #1703 from jeliasson/fix/azure-active-directory-de…
Browse files Browse the repository at this point in the history
…fault-auth-request

Azure Active Directory: Updating default auth request for acquireTokenSilent
  • Loading branch information
Tobbe committed Feb 1, 2021
2 parents 9554de3 + b06dd35 commit 44d234b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/auth/src/authClients/azureActiveDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const azureActiveDirectory = (
logout: (options?) => client.logout(options),
signup: async (options?) => await client.loginPopup(options),
getToken: async (options?: any) => {
const renewIdTokenRequest = options || {
scopes: [process.env.AZURE_ACTIVE_DIRECTORY_CLIENT_ID],
const authRequest = options || {
scopes: ['openid', 'profile'],
}

// The recommended call pattern is to first try to call AcquireTokenSilent,
Expand All @@ -26,10 +26,10 @@ export const azureActiveDirectory = (
// NOTE: We are not catching by the `MsalUiRequiredException`, perhaps we can branch off `error.name`
// if this strategy doesn't work properly.
try {
const response = await client.acquireTokenSilent(renewIdTokenRequest)
const response = await client.acquireTokenSilent(authRequest)
return response?.idToken?.rawIdToken || null
} catch (error) {
client.acquireTokenRedirect(renewIdTokenRequest)
client.acquireTokenRedirect(authRequest)
}

return null
Expand Down

0 comments on commit 44d234b

Please sign in to comment.