I am trying to use NextAuth as auth provider for my project. I have a requirement where I have Credential based login/password. In this case when I login I have to pass the username/password to the custom API (for ex.: abc.com/auth/login). This API as success will return me a JWT for future communication to access their resources.
What I understood from NextAuth that it maintain its own session and JWT(if DB not provided). This feature works in my case but I have to maintain the JWT which the API has returned me(mentioned above). So now there are two JWT one which I received from API and the one which NextAuth has created.
My question:
- Is there a way which I can use to maintain the custom JWT which I received from API?
- Is there a way if API token has been expired to tempered so I can kill NextAuth session.
- What is the best way to keep NextAuth Session and Custom JWT token in sync?
Thanks in advance!