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.

handleRedirectCallback returning null for authErr?

See original GitHub issue

Please follow the issue template below. Failure to do so will result in a delay in answering your question.

Library

  • @azure/msal@1.3.0
  • @azure/msal-browser@2.x.x
  • @azure/msal-angular@0.x.x
  • @azure/msal-angular@1.x.x
  • @azure/msal-angularjs@1.x.x

Important: Please fill in your exact version number above, e.g. msal@1.1.3.

Framework

If you are using a framework, please provide the framework and version (e.g. Angular v8, React v16, etc).

React 16

Description

type of this.userAgentApp.handleRedirectCallback is: handleRedirectCallback(authCallback: authResponseCallback): void; where authResponseCallback is: export declare type authResponseCallback = (authErr: AuthError, response?: AuthResponse) => void;

I have passed in a callback that fits this signature however, on first time load of the site when user logs in, authErr is null and the site crashes because of a TypeError

image

^errorCode is a property of AuthError type. Let me know if you need code example

Security

Is this issue security related?

No

Regression

Did this behavior work before?

Not sure

Configuration

Please provide your MSAL configuration options.

// Provide configuration values here.
// For Azure B2C issues, please include your policies.

{
      auth: {
        clientId: this.clientId,
        authority: this.authority,
        redirectUri: this.loginRedirectUri,
        postLogoutRedirectUri: this.postLogoutRedirectUri
      },
      cache: {
        cacheLocation: "localStorage",
        storeAuthStateInCookie: true
      },
      system: {
        logger: new Logger(MsalAuthContext.msalLoggerCallback, { level: LogLevel.Verbose, piiLoggingEnabled: false }),
        navigateFrameWait: 0
      }
    }

Reproduction steps

Not 100% reproducible…

Expected behavior

A clear and concise description of what you expected to happen.

I expect the callback to not be passed a null for authErr in the callback authResponseCallback = (authErr: AuthError, response?: AuthResponse) => void;

Browsers

Is this issue browser-specific? If so, please detail which browsers are impacted (e.g. IE 11, Safari).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tnorlingcommented, May 18, 2020

This will also be more clearly defined in the code when we turn on strictNullChecks which we are currently working on

Read more comments on GitHub >

github_iconTop Results From Across the Web

Access token is null in Msal response-Azure AD B2C
This simple code is all you need to get your access token (response type ... handleRedirectCallback(authCallback); const accessTokenRequest: ...
Read more >
Handle errors and exceptions in MSAL.js - Microsoft Entra
Learn how to handle errors and exceptions, Conditional Access claims challenges, and retries in MSAL.js applications.
Read more >
Top 5 @auth0/auth0-spa-js Code Examples - Snyk
To help you get started, we've selected a few @auth0/auth0-spa-js examples, based on popular ways it is used in public projects.
Read more >
UserAgentApplication | microsoft-authentication-libraries-for-js
Returns the signed in account (the account object is created at the time of successful login) or null when no state is found ......
Read more >
The Complete Guide to Vue.js User Authentication with Auth0
The Profile component renders user information that you could consider protected. Additionally, the user property is null if there is no logged-in user....
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