Closed hans642 closed 1 week ago
@hans642, just to be sure, your credentials match a registered customer right?
@hans642, just to be sure, your credentials match a registered customer right?
yes, use email and password can get the token, so credentials is matched
use email and password can get the token, so credentials is matched
You'll receive a token if the credentials match any identity, but that doesn't necessarily mean you have access to all authenticated endpoints. The identity need to be associated with the correct actor.
For example, if you are signed up as a user with these credentials, you will still receive a 200 + token when you call: POST 'http://localhost:9000/auth/customer/emailpass'
, but you won't be able to use the token to authenticate as a customer.
Can I get you to ensure your credentials match a customer, not a user?
use email and password can get the token, so credentials is matched
You'll receive a token if the credentials match any identity, but that doesn't necessarily mean you have access to all authenticated endpoints. The identity need to be associated with the correct actor.
For example, if you are signed up as a user with these credentials, you will still receive a 200 + token when you call:
POST 'http://localhost:9000/auth/customer/emailpass'
, but you won't be able to use the token to authenticate as a customer.Can I get you to ensure your credentials match a customer, not a user?
Thank you very much, i think i found the root case, a user or a customer all will return token, but the token info is different: Here is a user, not actor_id and customer_id
{
"actor_id": "",
"actor_type": "customer",
"auth_identity_id": "authid_01JDBD9QXWP465XTQ0MHTNTBDV",
"app_metadata": {},
"iat": 1732335623,
"exp": 1732422023
}
Here is a customer:
{
"actor_id": "cus_01JDHFF3YDHW9754Z7VMT9YM29",
"actor_type": "customer",
"auth_identity_id": "authid_01JDHFDVB55G4AXSDVSFTHRWX2",
"app_metadata": {
"customer_id": "cus_01JDHFF3YDHW9754Z7VMT9YM29"
},
"iat": 1732532263,
"exp": 1732618663
}
May i know if a user already record in database and user don't know the token, how to become a customer?
May i know if a user already record in database and user don't know the token, how to become a customer?
It depends on the flow, but in the scenario where you are registered as a user and want to use the same identity as a customer, you would do:
Authenticate
POST /auth/customer/emailpass
{ ...credentials }
Create customer
POST /store/customers
{ email: "..." }
{ authorization: Bearer ... }
Package.json file
Node.js version
v20.15.1
Database and its version
16.4
Operating system name and version
macOS 15.1
Browser name
No response
What happended?
When i use auth get token and the use this token get info will show Unauthorized
please help check, reference: https://docs.medusajs.com/api/store#authentication
Expected behavior
Can got correct info
Actual behavior
Will show Unauthorized
Link to reproduction repo
medusa(v2)