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.

Failing to acquire access token - Non-interactive error: block_token_requests

See original GitHub issue

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

Library

  • msal@1.x.x or @azure/msal@1.2.1

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

Framework

React v16.12.0

Description

I have 2 applications which are both protected by azure ad: a react app and an asp.net core web API. These applications are registered separately in Azure so each has its own client id. Users will get authenticated via the react app and in turn the react app will call the API. As of now users can successfully sign in but I can’t get an access token to call the API. I exposed the API and it has a scope like this: api://{web_api_client_id}/api.read. I tested the API via postman and its working. In the console I’m seeing the following informational messages: Token is not in cache for scope:openid profile user.read api://{web_api_client_id}/api.read, renewing accesstoken, renewToken is called for scope:openid profile user.read api://{web_api_client_id}/api.read. There is also an error I am not sure if it affects: Unsafe JavaScript attempt to initiate navigation for frame with origin ‘http://localhost:3000’ from frame with URL ‘https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize?response_type=token&scope=openid profile User.Read api%3A%{tenant_id}%2Fapi.read&client_id={react_app_client_id}&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fbusiness-units&state=4c9679db-e187-4531-a6c0-7f6b7d23d77c&nonce=c9cf0545-263c-4848-a03d-cdf051a4594c&client_info=1&x-client-SKU=MSAL.JS&x-client-Ver=1.2.1&login_hint={my_full_name}%40{my_domain.com}&login_req={user_account_identifier}&domain_req={tenant_id}&domain_hint=organizations&client-request-id=06c6df6e-34df-4909-be79-aa76fd5417c6&prompt=none&response_mode=fragment’. The frame attempting navigation of the top-level window is sandboxed, but the flag of ‘allow-top-navigation’ or ‘allow-top-navigation-by-user-activation’ is not set.

Security

Is this issue security related? No

Regression

Did this behavior work before? No

Configuration

Please provide your MSAL configuration options. `export const GRAPH_SCOPES = { OPENID: “openid”, PROFILE: “profile”, USER_READ: “User.Read”, MY_API: “api://{web_api_client_id}/api.read” };

export const GRAPH_ENDPOINTS = { ME: “https://graph.microsoft.com/v1.0/me” };

export const GRAPH_REQUESTS = { LOGIN: { scopes: [ GRAPH_SCOPES.OPENID, GRAPH_SCOPES.PROFILE, GRAPH_SCOPES.USER_READ, GRAPH_SCOPES.MY_API ] } };

export const msalApp = new UserAgentApplication({ auth: { clientId: “{react_app_client_id}”, authority: “https://login.microsoftonline.com/{tenant_id}”, redirectURI: “http://localhost:3000” }, cache: { cacheLocation: “localStorage”, storeAuthStateInCookie: isIE() }, system: { navigateFrameWait: 0, logger: { error: console.error, errorPii: console.error, info: console.log, infoPii: console.log, verbose: console.log, verbosePii: console.log, warning: console.warn, warningPii: console.warn } } });`

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

Reproduction steps

  1. npm start
  2. Click button to sign-in and login pop-up appears
  3. Enter username and password

Expected behavior

I expect that after user signs in the library will silently acquire an access token to call the API so that users can view the data from the API.

Browsers

Is this issue browser-specific? No, all browsers affected.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonnuttercommented, May 20, 2020

Great! You’re welcome.

I did notice this warning, however last I checked the latest msal.js version is 1.3.0

That warning is for customers looking to upgrade to @azure/msal-browser aka MSAL.js v2 (currently in Public Preview), which switches from the Implicit Flow to the Auth Code Flow. See: #1000

1reaction
oneillsp96commented, May 20, 2020

adding the check for !WindowUtils.isInIframe() fixed the blocked token request console error. checking the box for implicit grant for access token fixed the unsupported_response_type error.

Thanks a ton. I can tell you guys are working hard on MSAL and it is a lot nicer to work with than it was this time last year.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure AD authentication & authorization error codes
Open a support ticket with Microsoft to get this fixed. AADSTS50008, InvalidSamlToken - SAML assertion is missing or misconfigured in the token.
Read more >
Troubleshooting gargle auth
With gargle versions up to v1.0.0, you will probably see this: Auto-refreshing stale OAuth token. Error in get("refresh_oauth2.0", asNamespace(" ...
Read more >
ACCESS: How to resolve the error “Failed to generate token ...
ACCESS : How to resolve the error “Failed to generate token” after setting the “max-expiry” value in the Access Configuration. Ino Choi
Read more >
Management API Access Tokens - Auth0
Get Management API tokens. The first time you get a Management API token for testing is when you authorize a machine-to-machine application in...
Read more >
How To: Create Security Integration & User To Use With ...
To be able to achieve non-interactive token generation, ... Please see this guide on how to get the cURL statement to generate 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