• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

I need to deliver the Api token from the json response not the header

Modules
12
14
4.2k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    carlosgarts last edited by 3 Jul 2019, 07:28

    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?

    capture Api.JPG

    1 Reply Last reply Reply Quote 0
    • R
      rahul last edited by 3 Jul 2019, 10:20

      Hi,

      Do the following -

      1. Open 'app.php' file of config folder & add the below code in providers array

      Tymon\JWTAuth\Providers\LaravelServiceProvider::class,

      1. 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

      1 Reply Last reply Reply Quote 0
      • C
        carlosgarts last edited by 4 Jul 2019, 00:27

        Thanks Rahul you saved me

        1 Reply Last reply Reply Quote 0
        • C
          carlosgarts last edited by 5 Jul 2019, 20:04

          I got many difficulties applying the Api in the front End even after your solution, there are some steps missing yet:

          1. You must register the middleware for auth.jwt

          Capture23.JPG

          1. 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

          Capture24.JPG

          and that way you can use your Bagisto api with Nuxt.js official Auth module, at least it works for me

          1 Reply Last reply Reply Quote 0
          • 4 months later
          • S
            sandeep last edited by 23 Oct 2019, 17:58

            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?

            H Y 2 Replies Last reply 19 Aug 2020, 10:11 Reply Quote 0
            • about a month later
            • W
              wearecoders last edited by 28 Nov 2019, 08:22

              Thank you so much. It is a great help from bagisto Forums. Thanks again to all.

              1 Reply Last reply Reply Quote 1
              • 7 months later
              • H
                haratmalli @sandeep last edited by 22 Jun 2020, 07:46

                @sandeep did u find the solution, how to send token to further interact with apis

                1 Reply Last reply Reply Quote 0
                • about a month later
                • E
                  eolykab last edited by 3 Aug 2020, 09:02

                  Hi.

                  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](Screenshot from 2020-08-03 11.01.38.png image url)

                  1 Reply Last reply Reply Quote 0
                  • V
                    Vaishali Agarwal last edited by 4 Aug 2020, 16:08

                    @eolykab
                    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

                    1 Reply Last reply Reply Quote 0
                    • 15 days later
                    • Y
                      yomnademerdash @sandeep last edited by 19 Aug 2020, 10:11

                      @sandeep i have the same problem ! did you find a solution ?

                      1 Reply Last reply Reply Quote 0
                      • 22 days later
                      • R
                        rndwiga254 last edited by 10 Sept 2020, 06:53

                        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:

                        cartItem.put("token",sharedPref.getCustomerApiToken());
                        

                        On all objects that need to be authenticated. If stuck reach-out.

                        1 Reply Last reply Reply Quote 0
                        • 19 days later
                        • S
                          simi61193 last edited by 29 Sept 2020, 11:17

                          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

                          1 Reply Last reply Reply Quote 0
                          • devansh-webkul
                            devansh-webkul last edited by 1 Oct 2020, 07:27

                            Hi @simi61193

                            May, I know the full request data and URI you are hitting.

                            1 Reply Last reply Reply Quote 1
                            • 12 months later
                            • J
                              jignesh last edited by 23 Sept 2021, 07:43

                              Hello we are trying to use graphql api for admin authentication but we are facing 500 internal server error.

                              can you please assist is there anything we need to enable or install package for access.

                              thank you.

                              b5ebb5f3-ebbf-4c74-a71d-5d4d1c20456d-image.png

                              1 Reply Last reply Reply Quote 0
                              5 out of 14
                              • First post
                                5/14
                                Last post