medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
25.93k stars 2.6k forks source link

Generating Access Token #7876

Closed arimtiaz closed 4 months ago

arimtiaz commented 4 months ago

How can I generate access token? image

humbleEwan commented 4 months ago

Based on my experience with medusa, the admin panel does not use tokens. I'm guessing session something else, it was easier to just log in trough the browser, setup a panel and run tests from there, rather to figure out how it works.

arimtiaz commented 4 months ago

@humbleEwan Nah I am not trying to het admin panel token. What i Did is extended medusa to adapt multi vendor functionality now I have to test it for that I need access token to send post and get methods

humbleEwan commented 4 months ago

Then open the panel, go to settings, and select API key management option. Other than that I do not see any other way

arimtiaz commented 4 months ago

That one doesnt work but there is this doc that they have but i couldn't understand it. Do you mind giving it a look.

https://docs.medusajs.com/api/admin#authentication

humbleEwan commented 4 months ago

image It works fine.

arimtiaz commented 4 months ago

Did you have to add anything on the postman authentication?

humbleEwan commented 4 months ago

After I have the token I use it as a Bearer token

arimtiaz commented 4 months ago

So when you first sent the post request to the auth/token you didnt need any tokens?

humbleEwan commented 4 months ago

To get this JWT no. I only sent my email and password in the body. This is an authentication endpoint

sradevski commented 4 months ago

Hey all, you can use both session and JWT-based authentication with both Medusa v1 and v2. We are planning to use JWTs for authentication by default in v2 (but both methods are supported for now).

The auth flow in v2 looks like this:

  1. Call /auth/user/emailpass to login/signup - This will return a JWT token on success
  2. If you want to use sessions and pass auth as cookies, call /auth/session with the JWT token, which will initiate a session

Moreover, v2 will also support creating API keys that you can use for programatically calling the API.

For any additional discussions, please use Discord instead. thanks!