While i am trying to use the following code to authenticate the user
await oktaAuth.signInWithRedirect()
It gets redirected to okta and user is also validated but i am not able to get the value of authState.isAuthenticated as true
Can you guide me on this @andrea
I am using @okta/okta-react and @okta/okta-auth-js in my app.
Right, the /authorize call made by signInWithRedirect will send the user back to the redirect_uri. So while we know that that method appears to be working fine, we need to make sure your application knows what to do when Okta redirects back into your application. This is why I wanted to know if you were using the LoginCallback component to handle retrieving and storing the user’s tokens.
For example, in our sample app, the routes are configured as below:
Yes i had already took reference from the code that you have shared
const routes = useRoutes([
{
path: ‘/oidc/callback’,
component: {LoginCallback}
},
])
The above is the code block where i have implemented logincallback
but it isn’t working as expected
You shouldn’t need to manually handle the request to get the token, the LoginCallback component will do this for you.
If you haven’t yet, I’d recommend playing around with one of our sampleapps and/or guides to see if they work for you and then look at what is different about your set-up.