1. Authentication

Last updated 3 months ago

Requests to Moltin require an Authorization header containing your Bearer token. There are two token types; implicit and client_credentials. See Authentication for more details.

This guide will use the implicit grant type. This grant type can be thought of as READ ONLY and most commonly used client side.

Get your API keys

Head to the Moltin Dashboard, sign in, select your project and make a copy of your client_id.

Get an access token

Using the client_id, we can now make our very first API request. Inside your Terminal or command-line equivalent, make the following request:

curl -X POST https://api.moltin.com/oauth/access_token \
-d "client_id=XXXX" \
-d "grant_type=implicit"

A successful request will respond with something similar to:

"expires": 1537779121,
"identifier": "implicit",
"expires_in": 3600,
"access_token": "0e82127a8d9c20abb3d6e48561cbfe81448956ab",
"token_type": "Bearer"

Congratulations! ๐Ÿ™Œ

Now you'll want to make a copy of your access_token. This is your implicit Bearer token that is required for future requests.

You'll need to re-authenticate when the access_token expires.

Make a request with your access token

Let's go ahead and request a new Cart. We'll use the unique reference abc for the Cart. We'll need this when requesting the items, adding items and checking out.

Replace XXXX below with your access_token from above.

Inside your command-line, run the following cURL request:

curl https://api.moltin.com/v2/carts/abc \
-H "Authorization: Bearer XXXX"

You'll receive a response similar to:


Now that we have successfully authenticated and retrieved a Cart, in the next lesson we will add a custom item to the Cart.