Getting customer token and using it


#1

Hi,

I am using the sdk and would like to log a user in after I have requested the customer token is it up to me to handle adding auth headers and making requests because as I understand it the SDK should handle storing the token for use when needed?


#2

Hey @joe :wave:

Could you elaborate on your use case a little further? Are you trying to retrieve customer details or customer orders?

Using the JS SDK you can generate a customer JWT:

const { data: { token } } = await Moltin.Customers.Token(email, password)

Then with the returned token, get orders for that customer:

await Moltin.Orders.All(token)

#3

I want to let the customer login and retrieve their orders


#4

The example above will take care of that for you :smile: