-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Custom refresh token name. #635
Comments
This is also a problem for me. I feel like the refresh provider is very nearly there now but for this one thing. |
Do you wish to customize the Nuxt Auth response structure? Let's discuss |
I'm using djangorestframework-simplejwt (https://github.com/jazzband/djangorestframework-simplejwt/) and the token name that's returned from there isn't configurable either so I'm a bit stuck. I can obviously try and get that changes one way or the other but I was hoping that this library would act like the original nuxt-auth and allow it to be changed in here. |
@bodgerbarnett same here. I'm little bit stuck with DRF and JWT. Cannot change the name in both, front and back end. Now I'm using only Token Authentication. |
Could you please clarify, whether you mean a request going out from this call const auth = useAuth()
auth.refresh() Or a response from If I understand you correctly, you have a django server which handles the JWTs and you only use If this is the case, for now I could only suggest you to proxy requests from |
@phoenix-ru I mean the call that is made by nuxt-auth to referesh the token. Both manually via
and contains the refresh token in the body defined by field For now, I'm using the local provider from nuxt-auth. |
@N1K1TAS95 Could you please clarify, if that is the flow you are using:
Therefore your sign in endpoint But your token refresh endpoint Possible solution in case you can proxy requestsUsing Nuxt server routes// server/api/auth/refresh.post.ts
// Adapted from playground-refresh
import { createError, eventHandler, readBody } from 'h3'
export default eventHandler(async (event) => {
const body = await readBody<{ refreshToken: string }>(event)
if (!body.refreshToken) {
throw createError({
statusCode: 403,
statusMessage: 'Unauthorized, no refreshToken in payload'
})
}
const { accessToken, refreshToken } = await fetchTokenFromExternalBackend(body.refreshToken)
return {
token: {
accessToken,
refreshToken
}
}
}) Using other backend servicesCreate a proxy route which will translate Solution in the futureI will introduce a configuration based on json-pointer // nuxt.config.ts
export default defineNuxtConfig({
auth: {
provider: {
type: 'refresh',
refreshToken: {
refreshRequestTokenPointer: '/refresh'
}
},
}
}) |
@phoenix-ru I'm using Django for backend alongside to Django Rest Framework and djangorestframework-simplejwt to handle API authentication and authorization.
Yes, exatly. Thank you for the temporary solution, I'll try it while I wait for the new release of nuxt-auth. |
I will increase the priority of this issue based on how often it is requested (I linked two duplicate issues above). Will try to prioritize finding a solution this week if I have time for it. |
Describe the feature
Hi there!
I'm using nuxt-auth and refresh mode to manage JWT.
Obtaining new access and refresh token works fine, but not refreshing a token.
Nuxt-auth sends this JSON:
My back-end expects a JSON with field "refresh", so an 400 error is returned.
I wish to customize the name like so:
Thanks!
Additional information
No response
The text was updated successfully, but these errors were encountered: