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

Getting the Token from body and not from header #118

Closed
blackw212 opened this issue Jun 21, 2019 · 6 comments
Closed

Getting the Token from body and not from header #118

blackw212 opened this issue Jun 21, 2019 · 6 comments

Comments

@blackw212
Copy link

Hello,

I would like to use your plugin in my next personal project, as it simplifies things by a lot.
Yet i am curious, how could i achieve that once the Response message from the API server is sent, that i could grab the Token from the body? Currently having some issues in providing custom headers as response, which include the access token generated.

If i wasn't clear enough, please let me know and i will further explain!

Thank you in advance !

@d0whc3r
Copy link
Owner

d0whc3r commented Jun 21, 2019

Hi,
Now is no possible to get auth token from body. Token is get from header response.
Explain me what do you need and I take a look if I can adjust the code to do that

@blackw212
Copy link
Author

Hello,

Thank you for your reply! What i mean is that, after i make the POST request towards the server, i would like to get the Token from the Data received. I will add a screenshot to make it easier to understand.
res

As seen there, i have the access token returned in the Data. I would like to be able to grab it from there.

@blackw212
Copy link
Author

So hello once again,

Just realised that the header gets stripped down to that by VueJS when i try to console log the header from your Plugin. Is this normal?

If i use Postman to check my request, the Authorisation header is there and exists.

@blackw212
Copy link
Author

To get things more clear, this is the response i get using an Restapi Client (similar to Postman or so):
header_postman

And the image in my previous post, is what i get when i do the following:
this.$auth.login({ username: this.username, password: this.password, }).then((response) => { // eslint-disable-next-line console.log(response); })
Basically console logging the response i get after the promise.

Am i missing something here? This is driving me nuts...

@d0whc3r
Copy link
Owner

d0whc3r commented Jul 14, 2019

Sorry for waiting
#128
now you could get the token from where you want
using customToken function defined in loginData option.
customToken is a function that receives the response from axios login petition and must return a string that is the token to use

@d0whc3r
Copy link
Owner

d0whc3r commented Jul 14, 2019

changes are available in version 1.3.0

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