401 Unauthorized Error response

yes I was using AuthJs library and I am using signInWithRedirect instead of isAuthenticated method. Should I change that and use isAuthenticated and see if it creates a session?

Okay, so you use signInWithRedirect to handle the /authorize call. What redirect_uri do you provide in this call and does it correlate to a route within your application that is able to finish the login flow?

If you haven’t set this part up yet, I would recommend checking our handleRedirect() method which will store the tokens in the Token Manager for you (even if that means it needs to complete Authorization Code flow)

here is the thing, my goal is once I was authenticated from OKTA sign page and I was successfully able to get the access token and now while redirecting from OKTA sign page to my app redirect URI I was supposed to go to a landing page/homepage as a logged user. So that as a logged in user you know I should be able to do various activities in my app page. So as of now to your question whatever the redirect_uri I have right now in my OKTA config file in my code I haven’t configured a path of my landing page in route yet. Do you think that’s where I was not able to route to a landing page with user session of my app as a logged in user? if yes do you have any example how I can create routes to my landing page? and so this routing part usually should be in what file of project has to be done?

@andrea, I tried to see oktaAuth. to for the method handleredirect method and not able to see it. I have one more question after getting the access_token I was again calling /userinfo end point by passing retrieved access_token as bearer token as authorization and getting user details as well but still session is not getting created. So after that in order to set the session for the user and to route to hompage of my app? what method should i use? should i use router.push? or what? can you help me please with an standard example?

The best source of samples is going to be on Github, like the link I referenced earlier, as well as our older sample application here (warning that the previous link has the most up to date sample)

We also have some guides on our site that are worth a read:

If those don’t cover your use case/questions, you can also check our our Developer blog which has additional sample code: Blog | Okta Developer

Thank you andrea right now I was trying next-auth approach to integrating SSO so I am adding oktaProvider in optios.ts file as a one more provider and I was passing the okta config. but when I deployed in OCP cloud it’s not redirecting to the oktasign page or to my app landing page when i click on SSO link on the login page it’s just refreshing and doing nothing. but it was able to redirect when I am trying in the localhost. in dev after clicking on the sso link in the url it’s giving me this error: /login?callbackUrI=domainurl/login/prev&error=OAuthSignin