Get user and token from login response
See original GitHub issueI’m very confused which data vue-auth expects from which API calls. I currently login like this:
this.$auth.login({
body: this.data.body,
redirect: {name: redirect ? redirect.from.name : 'AdminHome'},
fetchUser: true,
success () {
this.success = true
}, error (res) {
console.log('error ' + res.data)
this.error = res.data
}
})
This API responds with this:
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUyZGJhNjczLWNjYzMtNDJkYi04NzQ1LWQ5ZTE5ZjBkYTRmMyIsIm5hbWUiOiJQZXJyeSIsInN1cm5hbWUiOiJOYXNlY2siLCJlbWFpbCI6IjE4bmFzZWNrcEBzbXRleGFzLm9yZyIsImRpc2FibGVkIjpmYWxzZSwicm9sZSI6MiwiZGV2aWNlSWQiOiI3YzU2NTUzYS1lZDI3LTQ1OWEtOGIxOC04MzA2N2MwMWU0MjUiLCJpYXQiOjE1MDA2NjA2NTcsImV4cCI6MTUwMTI2NTQ1N30.LjsW4fDJAUvZLWjAXDwAkikluwxiwEoxaLpG14SRqnE",
"data": {
"id": "52dba673-ccc3-42db-8745-d9e19f0da4f3",
"name": "ExFirstName",
"surname": "ExLastName",
"email": "exmaple@example.com",
"disabled": false,
"role": 2,
"deviceId": "7c56553a-ed27-459a-8b18-83067c01e425"
}
}
But then the library makes another call to api/user
, but it doesn’t include the token in that request, so my API doesn’t know what to do (well, really it just gives a 400 as it’s supposed to).
Also, is it supposed to decode the JWT to get the user data, or am I supposed to hand it to it in an object like this?
Thank you for making this awesome library and saving me a lot of time trying to implement a full auth system myself.
Issue Analytics
- State:
- Created 6 years ago
- Comments:39 (18 by maintainers)
Top Results From Across the Web
Get Access Tokens - Auth0
Learn how to request Access Tokens using the Authorize endpoint when authenticating users and include the target audience and scope of access requested...
Read more >Retrieve an Access Token and Refresh Token
After the user has completed entering their code, the Device Token Response you receive from Login with Amazon will contain the following parameters: ......
Read more >Get access on behalf of a user - Microsoft Graph
The first step to getting an access token for many OpenID Connect (OIDC) and OAuth 2.0 flows is to redirect the user to...
Read more >How get API response using username and password?
You likely need an auth interceptor, and need to utilize a refresh token. It's a lot to discover on a whim, but effectively...
Read more >How to get an access token with Authorization Code Grant
Before you can make any API calls using Authorization Code Grant, you must get your user's consent for your app to act for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://github.com/websanova/vue-auth/blob/master/docs/Guide.md#authentication--drivers
Hi @websanova or anyone, I still confused on how to set response data from login response.
Actually, I have implemented the custom authentication token, but I stuck on how to pass the login response and use it as “rolesVar”
my login response is:
on main.js:
And also, when I try to print the data on parseUserData, its return empty object
{}
on customAuth.js:
on login script:
please help me with this. I have been stuck with this for a week.