-
Notifications
You must be signed in to change notification settings - Fork 32
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
Getting "AuthSdkError: The app should not attempt to call authorize API on callback. Authorize flow is already in process. Use parseFromUrl() to receive tokens." error when trying to get access token and claims. #6
Comments
@ilgiznurgaliev - Thanks for the report, we will take a look and get back to you as soon as we can. |
See comments left on same issue here: okta/okta-oidc-js#863 (comment) We can continue conversation here, this is the new repository for the |
Hi and thank you for your responses. @aarongranick-okta, replying to your comment... As first solution you suggested:
I'm trying to achieve the following logic.
That's it, very simple. Now I want to add authentication through Okta to my application. You can see above what was changed in my code.
In this step everything works as expected. When I try to open my application url it redirects me to okta and after authentication Okta redirects me back to my application. I can see that url contains code and state GET parameters. So now within onInit function before API call I need to get access token and pass it to my PHP API, which will verify it before sending data to application.
Sorry if this is something simple but I'm new in angular don't really understand where is my mistake? |
"didn't add any 'Login' button, because entire my application (root path) will be protected" This may be the problem. The login callback route must be an unprotected route. Since the logic is occurring in the middle of an auth flow, the user is neither authenticated nor authenticated. Try to navigate to |
When I try to navigate directly to /login (http://localhost:4200/login) it doesn't redirect me to to Okta, it just opens the application. Also checked in chrome's network tab of debug console. Only when I try to open root path (http://localhost:4200/) it redirects me to Okta (https://dev-xxxxx.okta.com/oauth2/default/v1/authorize...) and then redirects back (http://localhost:4200/login...). |
It is a bit strange because according to this guide:
There is nothing about that the login callback route must be an unprotected route. |
@ilgiznurgaliev Thank you for bringing this issue with the documentation to our attention, we will correct this and be sure to mention that the callback must be an unprotected route. Since navigating to |
@aarongranick-okta I use builtin
Currently ngOnInit() function in app.component.ts looks like below:
no any errors and authentication flow works as expected, but when I'm trying to get access token and/or user:
authentication still works fine but getting the error in browser console. |
@ilgiznurgaliev Are you receiving the error on the callback route ('/login') or on the app route ('/') ? If the error is happening on the callback, make sure that none of the logic in app component runs (maybe add a If you are receiving the error on the app route (after authentication), check to see if there is a query parameter |
Hi, @aarongranick-okta. I'm receiving the error on the app route after authentication. Today I have found that when I reload the URL above that contains |
@ilgiznurgaliev You say you are "receiving the error on the app route", "yet the url looks like" Based on router config, the URL (with path
Try moving the route definition for `login' before the definition of '' |
Just tried to move /login route, so routes now looks like below:
But still getting the same error. Sorry for the misunderstanding, I said that I'm received the error in the app route because I'm trying to get access token within app component. |
@aarongranick-okta Found in documentation:
Tried console.log('From Uri: ', this.oktaAuth.getFromUri()); and got Probably I will need to copy the component to my own source and try to debug it to understand why |
@aarongranick-okta, I found finally where was my mistake. Angular didn't load Thank you very much for your help and your patience. |
Hi.
When I'm trying to get access token and claims as described here to pass it to PHP back end I'm getting the error above.
Part of
app.module.ts
:Part of
app.component.ts
:There is no other components and routes, all content is in root (/) path.
Authentication works fine, but I'm unable to get access token to pass it to back end written in php.
Could someone please assist to solve the issue?
The text was updated successfully, but these errors were encountered: