I need to deliver the Api token from the json response not the header
Hello, i'm working with a Nuxt.js project, i'm using Bagisto as backend and i need to get the Token from the JSON response not the header, when i log-in via API i get a "true" instead of the token.
What do i need to do to display the token in the JSON response?
rahul last edited by
Do the following -
- Open 'app.php' file of config folder & add the below code in providers array
- Run the following command from root of your project
php artisan jwt:secret
3: . Send token=true for login end point to get token
(eg. http://localhost/191/bagisto/public/api/customer/login?token=true )
Thanks Rahul you saved me
I got many difficulties applying the Api in the front End even after your solution, there are some steps missing yet:
- You must register the middleware for auth.jwt
- There are other steps in between but the current version of Bagisto got it done until the middleware in the Api routes, so you can add the middleware like this
and that way you can use your Bagisto api with Nuxt.js official Auth module, at least it works for me
sandeep last edited by
I got token in my Login API. How to use this Api to Add product in wishlist or Cart or any Api of customer data and order?
wearecoders last edited by
Thank you so much. It is a great help from bagisto Forums. Thanks again to all.
haratmalli last edited by
@sandeep did u find the solution, how to send token to further interact with apis
eolykab last edited by
Thanks this allows me to get the token. But however, I am getting a Cors issue. See the below image and please advise on how I can solve this. I am using VueJs in the front end.
![alt text]( image url)
Vaishali Agarwal last edited by
you may read this guide to fixup this issue https://medium.com/@dtkatz/3-ways-to-fix-the-cors-error-and-how-access-control-allow-origin-works-d97d55946d9
yomnademerdash last edited by
@sandeep i have the same problem ! did you find a solution ?
rndwiga254 last edited by
Heads up people!
After 6 hours of digging through the code base this line stood out:
$this->guard = request()->has('token') ? 'api' : 'customer';
It means even if you have the header set correctly, your mobile application will still not authenticate. So, to solve this, what you need to do is add:
On all objects that need to be authenticated. If stuck reach-out.
simi61193 last edited by
How can i use token for adding product to cart.
I got token from login api. but when i am using this token in cart add it respond 500 error