Okta next-auth integration [hackathon]

I am next.js application I am trying to connect okta as a provider with next-auth.
The Sign-in redirect URIs will be this right http://localhost:3000/api/auth/callback/okta?

I have been getting an error that I do not know how to solve.

Hey @trace, can you help me with which provider you are trying to use to login to your application? And to confirm are you using Prisma?

Yup using prisma. Provider Okta

Hi @trace, did you use this documentation for setup. Also any errors on your console or network tab?

Hey @sigama I did. Do you think the sign-in redirect URI I have mentioned above is correct?

I don’t see an error related to that to deduce that is the issue, or at least not with the information you shared. Is the redirect URI - http://localhost:3000/api/auth/callback/okta - the same URI you have listed in your Okta dashboard and is it a working route in your app?

The callback looks right to me per OAuth | NextAuth.js. @trace is that what you also have listed on Okta side?

Please also confirm you have your configurations set properly see for example - Okta Provider Error: only valid absolute URLs can be requested · Issue #5216 · nextauthjs/next-auth · GitHub.

Yes it should be a working route. I have Credential login too and that is working fine

Hey @sigama an update. I was missing @@unique([provider, providerAccountId]) in my schema. Adding that solved the issue. Thanks for the support

1 Like

@trace glad you figured it out!

1 Like

This is one article about " Adding Authentication to Next.js with NextAuth.js and Okta" that I find very helpful if you want to read more and improve your code: Adding Authentication to Next.js with NextAuth.js and Okta


Hey @Hong I did follow that article. My problem was happening because of the schema issue. Thanks for the response tho

1 Like