I've set up social authentication using dj-rest-auth / django allauth. The endpoint expects this info as JSON:
Unfortunately it seems to me like Nuxt Auth assumes the backend should extract the information from the URL, although it sends it as a POST-request. So what happens is: I click on continue with Google > Nuxt auth pushes me to google > Google pushes me to my callback URL with all the information present in the URL.. and Nuxt Auth grabs that URL and just sends it off as is.
So I'm left with two options:
- Do I attempt to modify the backend, which feels fairly troublesome.
- Do I somehow override Nuxt Auth? I'm fairly clueless here.
The docs talk about creating custom schemes: https://auth.nuxtjs.org/guide/scheme
But from that point I really can't figure out how to customize the actual post-request being made. Help would be appreciated.
MY NUXT.CONFIG.JS:
auth: {
redirect: {
login: '/register',
logout: false,
// callback: '/login',
home: '/bevakning'
},
strategies: {
google: {
scope: ['profile', 'email'],
codeChallengeMethod: '',
responseType: 'code',
endpoints: {
token: 'http://localhost:8000/social-login/google/',
userInfo: 'http://localhost:8000/auth/user/'
},
// withCredentials: true,
},
local: {
token: {
property: 'key',
type: 'Token ',
maxAge: 86400 * 120
},
user: {
// using property: false means it will use the entire json response as user and not just one variable.
property: false
// property: 'email'
},
endpoints: {
login: {
url: '/dj-rest-auth/login/ ',
method: 'post',
// propertyName: 'auth_token'
},
logout: {
url: '/dj-rest-auth/logout/',
method: 'post'
},
user: {
url: '/dj-rest-auth/user/',
method: 'get',
}
},
// tokenRequired: true,
// tokenType: 'Token ',
// globalToken: true,
autoFetchUser: true,
}
}
},
EDIT: Solved the issue I had, which unironically was caused by Axios overriding the nuxt auth method. I realized something was off when the content-type was set to JSON, yet the body was sent as if it was x-www-urlencoded.