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.

PasswordFlow with Cookie-Storage does not work each time

See original GitHub issue

Hey,

first of all, thank you for your create work and my bad english 😃.

I tried different storage solutions but i need to use the cookie storage for login on different subdomains.

My Angular Version is 7 and had the same on 6.

Sometimes after calling the login with PasswordFlow:

fetchTokenUsingPasswordFlowAndLoadUserProfile(email, password) .then((user) => { // OK }) .catch((err) => { // ERROR });

i will get an error (but not in chrome, only in Safari or Firefox). As an cookie storage i used this one:

https://www.npmjs.com/package/cookie-storage

I checked what could be the problem. Login is successfull and the access_token is stored as an cookie but i think not fast enough.

After checking the code, i found one part that could be a problem:

https://github.com/manfredsteyer/angular-oauth2-oidc/blob/0274cf5c03080e2a139abbf84d2bb9dd2480f3c2/projects/lib/src/oauth-service.ts#L688

storeAccessTokenResponse is called on token response but async. it resolves the token response but the caller in line 562 https://github.com/manfredsteyer/angular-oauth2-oidc/blob/0274cf5c03080e2a139abbf84d2bb9dd2480f3c2/projects/lib/src/oauth-service.ts#L562 doesnt work with the response and calls the

https://github.com/manfredsteyer/angular-oauth2-oidc/blob/0274cf5c03080e2a139abbf84d2bb9dd2480f3c2/projects/lib/src/oauth-service.ts#L574

method wich checks the access token first.

if the browser or the storage is not fast enough, the access token check says that the token is not valid because it doesnt exists.

Is it possible to return the token response and work with it instead checking the storage?

Thanks

David

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
davidk85commented, Nov 14, 2018

Yes, your right. Thanks for your support.

0reactions
zeroregardcommented, Aug 5, 2020

What was the exact solution to this? Did you have to change something on your authentication service (specifically this ‘CookieStorage’ part by @davidk85), or did you do some magic within your Angular project?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure custom OAuthStorage - angular-oauth2-oidc
We need a factory, since localStorage is not available during AOT build time. export function storageFactory() : OAuthStorage { return localStorage } ...
Read more >
how to retrieve jwt stored in cookies - node.js - Stack Overflow
the problem was a CORS error, must include credentials: "include" in the logout fetch request header.
Read more >
amazon-cognito-identity-js - npm
Your User Pool in Amazon Cognito is a fully managed user directory that can scale to hundreds of millions of users, so you...
Read more >
An Introduction To Session-based Authentication In Rust
We build - from scratch - an admin dashboard in Rust. It will include a login form, a logout button and a form...
Read more >
Spring REST API + OAuth2 + Angular (using the ... - Baeldung
The Authorization Server can use any TokenStore type [JdbcTokenStore, JwtTokenStore, …] – this won't affect the RemoteTokenService or Resource ...
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