Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent AccessToken Requests Not Working? #274

Closed
spottedmahn opened this issue Mar 23, 2018 · 2 comments
Closed

Concurrent AccessToken Requests Not Working? #274

spottedmahn opened this issue Mar 23, 2018 · 2 comments

Comments

@spottedmahn
Copy link
Contributor

When I make multiple concurrent requests for an access token I've receiving timeouts and multiple B2C requests to get an access token; it is not pulling from cache storage.

I'm about 98% confident this was working w/ 0.1.3. There have been some changes to our app but not much w/ regards to these components.

Please see the MSAL.js log below.

See how there are multiple requests to get access tokens within seconds of each other?

VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:31 GMT:12345-0.1.4-Verbose renewing accesstoken
VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:33 GMT:12345-0.1.4-Info Fragment has access token
VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:33 GMT:12345-0.1.4-Verbose Window is in iframe, acquiring token silently

VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:34 GMT:12345-0.1.4-Verbose renewing accesstoken
VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:36 GMT:12345-0.1.4-Info Fragment has access token
VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:36 GMT:12345-0.1.4-Verbose Window is in iframe, acquiring token silently

Version: 0.1.4

public getAccessToken(): Observable<string> {

	this.debug(`trying to obtain an access token`);

	let tokenPromise = this.msalLogin.acquireTokenSilent(environment.auth.scopes)
		.then(token => {
			this.debug('obtained an access token');

			return token;
		}).catch(error => {
			if (error && error.includes('timeout'))
				console.error(`could not re-authenticate silently, redirecting to log in; error: ${error}`);
			else
				console.log(`could not re-authenticate silently, redirecting to log in; error: ${error}`);

			this.msalLogin.acquireTokenRedirect(environment.auth.scopes);
			return '';
		});

	return Observable.fromPromise(tokenPromise);
}
### MSAL Log >VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:09 GMT:12345-0.1.4-Info Returned from redirect url VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:09 GMT:12345-0.1.4-Info State status:true; Request type:renewToken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:09 GMT:12345-0.1.4-Info State is right VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:09 GMT:12345-0.1.4-Info Fragment has access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:09 GMT:12345-0.1.4-Verbose acquiring token interactive in progress VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:09 GMT:12345-0.1.4-Error Error occurred in token received callback function: TypeError: Cannot read property 'getUser' of undefined VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 Angular is running in the development mode. Call enableProdMode() to enable the production mode. [Violation] 'load' handler took ms [Violation] 'load' handler took ms [Violation] 'load' handler took ms [Violation] 'load' handler took ms [Violation] 'load' handler took ms VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:10 GMT:12345-0.1.4-Verbose renewing accesstoken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:10 GMT:12345-0.1.4-Verbose renewToken is called for scope:https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:10 GMT:12345-0.1.4-Info Add msal frame to document:msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:10 GMT:12345-0.1.4-Verbose Renew token Expected state: 57f26b93-d46a-440d-888f-3d6fa6277dfd VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:10 GMT:12345-0.1.4-Verbose Set loading state to pending for: https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:10 GMT:12345-0.1.4-Info LoadFrame: msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:10 GMT:12345-0.1.4-Info Add msal frame to document:msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:12 GMT:12345-0.1.4-Info Returned from redirect url VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:12 GMT:12345-0.1.4-Info State status:true; Request type:renewToken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:12 GMT:12345-0.1.4-Info State is right VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:12 GMT:12345-0.1.4-Info Fragment has access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:12 GMT:12345-0.1.4-Verbose Window is in iframe, acquiring token silently VM347 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM347 main.d197a3d4fc940bbf923d.bundle.js:1 Angular is running in the development mode. Call enableProdMode() to enable the production mode. VM313 main.d197a3d4fc940bbf923d.bundle.js:1 obtained an access token [Violation] Forced reflow while executing JavaScript took 34ms VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 [Violation] 'click' handler took 167ms VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:31 GMT:12345-0.1.4-Verbose renewing accesstoken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:31 GMT:12345-0.1.4-Verbose renewToken is called for scope:https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:31 GMT:12345-0.1.4-Info Add msal frame to document:msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:31 GMT:12345-0.1.4-Verbose Renew token Expected state: b556075b-e511-4f0f-9553-f1e46d37d18b VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:31 GMT:12345-0.1.4-Verbose Set loading state to pending for: https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:31 GMT:12345-0.1.4-Info LoadFrame: msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:31 GMT:12345-0.1.4-Info Add msal frame to document:msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:32 GMT:12345-0.1.4-Info Returned from redirect url VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:32 GMT:12345-0.1.4-Info State status:true; Request type:renewToken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:32 GMT:12345-0.1.4-Info State is right VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:33 GMT:12345-0.1.4-Info Fragment has access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:33 GMT:12345-0.1.4-Verbose Window is in iframe, acquiring token silently VM383 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM383 main.d197a3d4fc940bbf923d.bundle.js:1 Angular is running in the development mode. Call enableProdMode() to enable the production mode. VM313 main.d197a3d4fc940bbf923d.bundle.js:1 obtained an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 [Violation] 'click' handler took 177ms VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:34 GMT:12345-0.1.4-Verbose renewing accesstoken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:34 GMT:12345-0.1.4-Verbose renewToken is called for scope:https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:34 GMT:12345-0.1.4-Info Add msal frame to document:msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:34 GMT:12345-0.1.4-Verbose Renew token Expected state: 563a5913-c734-4a5f-8203-21484e8fb201 VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:34 GMT:12345-0.1.4-Verbose Set loading state to pending for: https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:34 GMT:12345-0.1.4-Info LoadFrame: msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:35 GMT:12345-0.1.4-Verbose Renew token for scope: https://myb2ctenant.onmicrosoft.com/webapi/no-op is in progress. Registering callback VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:35 GMT:12345-0.1.4-Info Add msal frame to document:msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:36 GMT:12345-0.1.4-Info Returned from redirect url VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:36 GMT:12345-0.1.4-Info State status:true; Request type:renewToken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:36 GMT:12345-0.1.4-Info State is right VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:36 GMT:12345-0.1.4-Info Fragment has access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:36 GMT:12345-0.1.4-Verbose Window is in iframe, acquiring token silently VM417 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM417 main.d197a3d4fc940bbf923d.bundle.js:1 Angular is running in the development mode. Call enableProdMode() to enable the production mode. VM313 main.d197a3d4fc940bbf923d.bundle.js:1 obtained an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 obtained an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:40 GMT:12345-0.1.4-Verbose renewing accesstoken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:40 GMT:12345-0.1.4-Verbose renewToken is called for scope:https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:40 GMT:12345-0.1.4-Info Add msal frame to document:msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:40 GMT:12345-0.1.4-Verbose Renew token Expected state: 3470e077-f438-4cdf-8eac-b18491abdaa7 VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:40 GMT:12345-0.1.4-Verbose Set loading state to pending for: https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:40 GMT:12345-0.1.4-Info LoadFrame: msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:40 GMT:12345-0.1.4-Verbose Renew token for scope: https://myb2ctenant.onmicrosoft.com/webapi/no-op is in progress. Registering callback VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:41 GMT:12345-0.1.4-Verbose Renew token for scope: https://myb2ctenant.onmicrosoft.com/webapi/no-op is in progress. Registering callback VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:41 GMT:12345-0.1.4-Info Add msal frame to document:msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:41 GMT:12345-0.1.4-Verbose Renew token for scope: https://myb2ctenant.onmicrosoft.com/webapi/no-op is in progress. Registering callback VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:42 GMT:12345-0.1.4-Info Returned from redirect url VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:42 GMT:12345-0.1.4-Info State status:true; Request type:renewToken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:42 GMT:12345-0.1.4-Info State is right VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:42 GMT:12345-0.1.4-Info Fragment has access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:10:42 GMT:12345-0.1.4-Verbose Window is in iframe, acquiring token silently VM459 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM459 main.d197a3d4fc940bbf923d.bundle.js:1 Angular is running in the development mode. Call enableProdMode() to enable the production mode. VM313 main.d197a3d4fc940bbf923d.bundle.js:1 obtained an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 obtained an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 obtained an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 obtained an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 trying to obtain an access token VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:11:00 GMT:12345-0.1.4-Verbose renewing accesstoken VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:11:00 GMT:12345-0.1.4-Verbose renewToken is called for scope:https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:11:00 GMT:12345-0.1.4-Info Add msal frame to document:msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:11:00 GMT:12345-0.1.4-Verbose Renew token Expected state: b5d1dca9-38c3-4010-a386-5876e078ec65 VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:11:00 GMT:12345-0.1.4-Verbose Set loading state to pending for: https://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:11:00 GMT:12345-0.1.4-Info LoadFrame: msalRenewFramehttps://myb2ctenant.onmicrosoft.com/webapi/no-op VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:11:00 GMT:12345-0.1.4-Verbose Renew token for scope: https://myb2ctenant.onmicrosoft.com/webapi/no-op is in progress. Registering callback VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:11:01 GMT:12345-0.1.4-Verbose Renew token for scope: https://myb2ctenant.onmicrosoft.com/webapi/no-op is in progress. Registering callback VM313 main.d197a3d4fc940bbf923d.bundle.js:1 msal.js: Thu, 22 Mar 2018 19:11:01 GMT:12345-0.1.4-Verbose Loading frame has timed out after: 30 seconds for scope https://myb2ctenant.onmicrosoft.com/webapi/no-op VM299:34 could not re-authenticate silently, redirecting to log in; error: Token renewal operation failed due to timeout: Token Renewal Failed window.console.error @ VM299:34
@rohitnarula7176
Copy link
Contributor

@spottedmahn I apologize for the late response. I was busy working on build related stuff.
Can you please try the latest dev branch and see if it resolves the issue.

I just created a test case to send multiple acquireToken requests for different scopes on app start and was able to get access token for all requests using the latest code.

@spottedmahn
Copy link
Contributor Author

Seems to be good now, thanks 🙏

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants