Customer Tokens

Last updated 9 days ago

We provide a basic /tokens endpoint that allows you authenticate customers by email and password so you can easily allow customers to manage their addresses or filter orders by customer.

The customer token object

Attributes
Sample Response

Attribute

Type

Description

id

string

The unique identifier for this otken

type

string

The type represents the object being returned

customer_id

string

The ID of the customer from which the token is generated

token

string

The JSON Web Token to be used for other endpoints

expires

timestamp

The epoch time that this token expires at

{
"data": {
"type": "token",
"id": "36f05940-0d38-411a-8909-3aea58bc1f09",
"customer_id": "79cc0486-bbdf-491b-a0a2-722383b6288b",
"token": "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJzdWIiOiI3OWNjMDQ4Ni1iYmRmLTQ5MWItYTBhMi03MjIzODNiNjI4OGIiLCJuYW1lIjoiUm9uIFN3YW5zb24iLCJleHAiOjE1MTA2ODQyMDAsImlhdCI6MTUxMDU5NzgwMCwianRpIjoiMzZmMDU5NDAtMGQzOC00MTFhLTg5MDktM2FlYTU4YmMxZjA5In0=.ea948e346d0683803aa4a2c09441bcbf7c79bd9234bed2ce8456ab3af257ea9f",
"expires": 1510684200
}
}

post
Generate a token

https://api.moltin.com
/v2/customers/tokens
Request
Response
Headers
Authorization
required
string
The Bearer token to grant access to the API
Body Parameters
password
required
string
The customer password
email
required
string
The customer email
type
required
string
This must be token
200: OK
{
"data": {
"type": "token",
"id": "36f05940-0d38-411a-8909-3aea58bc1f09",
"customer_id": "79cc0486-bbdf-491b-a0a2-722383b6288b",
"token": "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJzdWIiOiI3OWNjMDQ4Ni1iYmRmLTQ5MWItYTBhMi03MjIzODNiNjI4OGIiLCJuYW1lIjoiUm9uIFN3YW5zb24iLCJleHAiOjE1MTA2ODQyMDAsImlhdCI6MTUxMDU5NzgwMCwianRpIjoiMzZmMDU5NDAtMGQzOC00MTFhLTg5MDktM2FlYTU4YmMxZjA5In0=.ea948e346d0683803aa4a2c09441bcbf7c79bd9234bed2ce8456ab3af257ea9f",
"expires": 1510684200
}
}
cURL
JavaScript SDK
curl -X POST https://api.moltin.com/v2/customers/tokens \
-H "Content-Type: application/json" \
-H "Authorization: Bearer XXXX" \
-d $'{
"data":{
"type": "token",
"email": "ron@swanson.com",
"password": "mysecretpassword"
}
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X'
})
const customer = {
email: 'ron@swanson.com',
password: 'mysecretpassword'
}
Moltin.Customers.Token(customer).then(data => {
// Do something
})