Authenticate

To be recognized as merchant you must authenticate and send the access_token in all your requests.

Login

Musement uses OAuth2 client_credentials flow to identify client applications. For a good explanation of the client_credentials flow please refer to this [article on Digital Ocean] ](https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2#grant-type-client-credentials)

To get your tokens you need to call the login endpoint using your client_id and client_secret.

curl -X GET \
  'https://sandbox.musement.com/api/v3/login?client_id=hereYouClientId&client_secret=hereYouClientSecret&grant_type=client_credentials' \
  -H 'Cache-Control: no-cache' \
  -H 'X-Musement-Version: 3.4.0'

and you will get a response like

{
    "access_token": "thisIsYourAccessToken",
    "expires_in": 3600,
    "token_type": "bearer",
    "scope": "user, password"
}

You now have to send the access_token in all your requests in the Authentication header.

curl -X GET \
  https://sandbox.musement.com/api/v3/activities/14ee2e2a-2046-11e7-9cc9-06a7e332783f/dates/2018-09-11 \
  -H 'Authorization: Bearer thisIsYourAccessToken' \
  -H 'Cache-Control: no-cache' \
  -H 'X-Musement-Currency: USD' \
  -H 'X-Musement-Version: 3.4.0'

The access_token allow Musement to identify you and retrieve custom fields. In the response for the request above if you send a valid token you will get a merchant_price field that you don't get if you are not authenticated.

Here you can see the response for authenticated client and for non authenticated clients. Please note that the second one has no merchant_price.

[..]
{
    "holder_code": "adult",
    "name": "Adult (12+)",
    "type": "musement",
    "default": false,
    "product_id": "1069604892",
    "min_buy": 1,
    "max_buy": 15,
    "availability": 37,
    "original_retail_price": {
        "currency": "USD",
        "value": 96,
        "formatted_value": "$ 96.00"
    },
    "discount_amount": {
        "currency": "USD",
        "value": 0,
        "formatted_value": "$ 0.00"
    },
    "retail_price": {
        "currency": "USD",
        "value": 96,
        "formatted_value": "$ 96.00"
    },
    "merchant_price": {
        "currency": "USD",
        "value": 76.32,
        "formatted_value": "$ 76.32"
    }
},
[..]
[..]
{
    "holder_code": "adult",
    "name": "Adult (12+)",
    "type": "musement",
    "default": false,
    "product_id": "1069604892",
    "min_buy": 1,
    "max_buy": 15,
    "availability": 37,
    "original_retail_price": {
        "currency": "USD",
        "value": 96,
        "formatted_value": "$ 96.00"
    },
    "discount_amount": {
        "currency": "USD",
        "value": 0,
        "formatted_value": "$ 0.00"
    },
    "retail_price": {
        "currency": "USD",
        "value": 96,
        "formatted_value": "$ 96.00"
    }
},
[..]