Skip to content
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

Use secured API in nextjs #22

Open
Misiu opened this issue Oct 11, 2021 · 3 comments
Open

Use secured API in nextjs #22

Misiu opened this issue Oct 11, 2021 · 3 comments

Comments

@Misiu
Copy link

Misiu commented Oct 11, 2021

Is your feature request related to a problem? Please describe.
I was searching for a clean way to use ASP. NET 5 API protected by identity server 4 in Nextjs. I found your. Repo, but sadly there is no sample how to use the secured API in next. I need SSR, SSG and client side usage.

Describe the solution you'd like
Ideally the next example should show how to register and login using Identity Server 4 and Authnext and how to call protected API using nextjs on both client side and server side (Ssr).

Describe alternatives you've considered
No alternatives :)

Additional context

@baotoq
Copy link
Owner

baotoq commented Apr 15, 2024

@Misiu we now have the next-auth example with server side and client access token retrieve

@Misiu
Copy link
Author

Misiu commented Apr 15, 2024

@baotoq thank you for the update.
One question about session management before I jump into code.
This is a typical situation with the next-auth.
Let's say your front is trying to make 5 requests to a protected API using an expired access token.
The first call will get 401, then it will use the refresh token to obtain a new access token and new refresh token and finally will succeed, but the rest of the requests will use the old refresh token and will fail to refresh the access and refresh tokens.
How will that work in your code?

I didn't watch your repo for a long time, but now I see many good things, especially .NET * and Aspire. Definitively will dig into the code :)

@baotoq
Copy link
Owner

baotoq commented Apr 15, 2024

have no idea how other people do it. but will copy some best practices from other repos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants