question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auth code grant stuck on authorization code

See original GitHub issue

Core Library

MSAL.js v2 (@azure/msal-browser)

Core Library Version

2.23.0

Wrapper Library

MSAL React (@azure/msal-react)

Wrapper Library Version

1.3.2

Description

We have been using this same Aure app registration, redirect, etc for over 2 years without any issues but over the past few days, our auth flow has been failing. To eliminate application errors I followed the code demo in the documentation and got the same issue described below:

  • The user is prompted to enter their email in popup
  • User is redirected to the login page in popup
  • The auth code is seen coming back in the URL

Auth flow simply stalls here. No errors, no prompts, no pending requests. Code is taken directly from the tutorial here: https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-react

Error Message

No response

Msal Logs

SAL AUTH LOGGING] [Mon, 25 Apr 2022 03:03:48 GMT] : @azure/msal-browser@2.23.0 : Info - Emitting event: msal:handleRedirectStart authConfig.js:17 [MSAL AUTH LOGGING] [Mon, 25 Apr 2022 03:03:48 GMT] : [06f236fd-cf44-475d-b2c1-46e095a4b4f5] : msal.js.browser@2.23.0 : Info - handleRedirectPromise called but there is no interaction in progress, returning null. 2authConfig.js:17 [MSAL AUTH LOGGING] [Mon, 25 Apr 2022 03:03:48 GMT] : @azure/msal-react@1.3.2 : Info - MsalProvider - msal:handleRedirectStart results in setting inProgress from startup to handleRedirect authConfig.js:17 [MSAL AUTH LOGGING] [Mon, 25 Apr 2022 03:03:48 GMT] : @azure/msal-browser@2.23.0 : Info - Emitting event: msal:handleRedirectEnd 2authConfig.js:17 [MSAL AUTH LOGGING] [Mon, 25 Apr 2022 03:03:48 GMT] : @azure/msal-react@1.3.2 : Info - MsalProvider - msal:handleRedirectEnd results in setting inProgress from handleRedirect to none authConfig.js:17 [MSAL AUTH LOGGING] [Mon, 25 Apr 2022 03:03:56 GMT] : @azure/msal-browser@2.23.0 : Info - Emitting event: msal:loginStart authConfig.js:17 [MSAL AUTH LOGGING] [Mon, 25 Apr 2022 03:03:56 GMT] : @azure/msal-react@1.3.2 : Info - MsalProvider - msal:loginStart results in setting inProgress from none to login authConfig.js:17 [MSAL AUTH LOGGING] [Mon, 25 Apr 2022 03:03:56 GMT] : @azure/msal-react@1.3.2 : Info - MsalProvider - msal:loginStart results in setting inProgress from none to login authConfig.js:17 [MSAL AUTH LOGGING] [Mon, 25 Apr 2022 03:03:56 GMT] : @azure/msal-browser@2.23.0 : Info - Emitting event: msal:popupOpened

MSAL Configuration

{
    auth: {
      clientId: "<clientId>",
      authority: "https://login.microsoftonline.com/<tenentId>", // This is a URL (e.g. https://login.microsoftonline.com/{your tenant ID})
      redirectUri: "<redirectUrl>/redirect.html",
    },
    cache: {
      cacheLocation: "sessionStorage", // This configures where your cache will be stored
      storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge
    }
  }

Relevant Code Snippets

import { useMsal } from "@azure/msal-react";

function handleLogin(instance) {
    instance.loginPopup(loginRequest).catch(e => {
        console.error(e);
    });
}

Reproduction Steps

  1. build out sample app from tutorial
  2. plug in relevant msal config info
  3. click login button
  4. observe auth flow stall in popup on code return

Expected Behavior

Auth flow completes, tokens are retrieved and set in sessionStorage

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

Chrome

Regression

No response

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
its-miller-timecommented, May 2, 2022

Apologies for the delayed follow up. Dug into this an found it was a conflict in a minor version of react-router. Not sure which one, needed to get a fix out so I pinned it to the lowest minor version. Try taking the caret out of your dependencies list for react-router-dom and related dependancies.

0reactions
hectormmgcommented, May 2, 2022

Thanks, closing the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authorization OAuth 2.0: Request Authorization Code not ...
I am not sure if related, but our /auth route has multiple stages, and it seems postman closes the login window before it...
Read more >
Authorization Code Grant — OAuthLib 3.2.1 documentation
The authorization code grant type is used to obtain both access tokens and refresh tokens and is optimized for confidential clients.
Read more >
401/Unauthorized when obtaining token in Authorization ...
When using the react-auth0-spa.js and the auth0-spa-js, I have to go through an awkward sequence to make my Authorization Code grant work ...
Read more >
OAuth2 Authorization code was already redeemed
AADSTS54005: OAuth2 Authorization code was already redeemed, please retry with a new valid code or use an existing refresh token.
Read more >
Docusign OAuth2 Authorization Code flow gets stuck when ...
User signs in to DocuSign using their email address · They click "allow" on the permission prompt · Docusign prompts them with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found