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

Error when first time acquire access token for resource #45

Open
vzdesic opened this issue Jul 10, 2018 · 3 comments
Open

Error when first time acquire access token for resource #45

vzdesic opened this issue Jul 10, 2018 · 3 comments

Comments

@vzdesic
Copy link

vzdesic commented Jul 10, 2018

Hello, when I am trying to fetch access Token in my Angular 5 application for the first time after user is logged in, with following method:

adalService.acquireToken(resource)

and I am getting this error:

AuthCallbackComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: Cannot read property '12345678-abcd-efgh-9876-1fa334df7c72|87654321-asdf-48b2-b9ca-111222333444' of undefined
at Adal5Service.handleWindowCallback (adal-angular5.js:77)
at LoginService.completeAuthentication (login.service.ts:80)
at AuthCallbackComponent.ngOnInit (callback.component.ts:17)

Resource is an API defined on AAD. Login service is my angular service which calls Adal5Service.handleWindowCallback function in this code, during standard, complete authentication, action:

...
public completeAuthentication(): void {
this.adalService.handleWindowCallback();
}
...

Second time Token is received without errors, but I don't want to implement retries. I would rather understand what is going wrong here. Any similar problem faced by anyone?

Thanks a lot. Vedran

@vzdesic
Copy link
Author

vzdesic commented Jul 13, 2018

Error explained in a post above was raised when using latest adal-angular5 and adal-angular versions, but I played with versions in a meantime. When I use following combination:
"adal-angular": "^1.0.15",
"adal-angular5": "^1.0.36",
nothing happens, I only see warning:
WebSocket connection to 'ws://localhost:4200/sockjs-node/571/zpdard4p/websocket' failed: WebSocket is closed before the connection is established.

Also, instances of my global providers are multiplied, what is strange. Somehow application bootstrap is done multiple times.

Thanks, Vedran

@vzdesic
Copy link
Author

vzdesic commented Aug 28, 2018

Hi,

Can anyone help here? I am using now 2.1.1 version of adal-angular5 and still error mentioned in my question remains. It happens in this line of code inside else-if of the adal-angular5.js file:

...
else if (requestInfo.requestType === this.adalContext.REQUEST_TYPE.RENEW_TOKEN) {
                this.adalContext.callback = ((window.parent)).callBackMappedToRenewStates[requestInfo.stateResponse];
}
...

requestInfo.stateResponse has a value: '12345678-abcd-efgh-9876-1fa334df7c72|87654321-asdf-48b2-b9ca-111222333444'

and error is:
TypeError: Cannot read property '12345678-abcd-efgh-9876-1fa334df7c72|87654321-asdf-48b2-b9ca-111222333444' of undefined
at Adal5Service.handleWindowCallback (adal-angular5.js:77)

Again, error is there only when calling aquireToken first time. If I repeat the call there is no error.

Also, there is still problem that instances of my global providers are multiplied. Somehow application bootstrap is done multiple times.

Thanks,
Vedran

@mausumit
Copy link

Hi,

I am also facing the same issue with few more issues.
The app loads 2-3 times. After that I see two errors in console

  1. ERROR TypeError: Cannot read property '4730d8bd-c126-49b3-9714-e7c2c3f56b09|427757c9-9aeb-488c-b149-db1d54c2c3c4' of undefined
    at Adal5Service.push../node_modules/adal-angular5/esm5/adal-angular5.js.Adal5Service.handleWindowCallback (adal-angular5.js:77)

  2. ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'access_token'
    Error: Cannot match any routes. URL Segment: 'access_token'.

Now if I reload the page, the erros are gone.
3. I am using a version 2.1.1. In node_modules\adal-angular5\esm5\adal-angular5.js the Observable is imported as "import { Observable as Observable$1 } from 'rxjs/Rx';" but in function below 'Observable ' is used instead of 'Observable$1) which is throwing error.

  1. In sendRequest method, the token is appended twice and API authorization is failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants