Authentication with the MakeLeaps app via our API is a quick and easy two-step process.
We make use of OAuth2 to authenticate API users, which is as simple as retrieving a token and passing it via the Authorization header in your following requests to MakeLeaps.
*New Bearer Tokens can be requested at any time and any amount of times, so there is no need to save them, infact, for security reasons we recommend against it.
Retrieve an access token by sending a POST request to https://api.makeleaps.com/user/oath2/token/.
The request should have a valid Authorization header in the form Basic "<your_client_id>:< your_client_secret>" with your credentials base64 encoded and "{ "grant_type": "client_credentials" }" in the POST body.
url = 'https://api.makeleaps.com/user/oauth2/token/' creds = '{self.client_id}:{self.client_secret}'.encode('utf-8') creds_encoded = base64.b64encode(creds).decode('utf-8') headers = {'Authorization': 'Basic {creds_encoded}'} data = {'grant_type': 'client_credentials'} response = requests.post(url, data=data, headers=headers)
POST /user/oauth2/token/ HTTP/1.1 Host: api.makeleaps.com User-Agent: python-requests/2.21.0 Accept-Encoding: gzip, deflate Accept: */* Connection: keep-alive Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX== Content-Length: 29 Content-Type: application/x-www-form-urlencoded grant_type=client_credentials
Retrieve the Bearer token from the server’s response.
The server’s response will contain this object containing the token’s information:
{"access_token": "XXXXXXXX", "token_type": "Bearer", "expires_in": 36000, "scope": "read write"}
Pass the Bearer token in the Authorization header in future requests preceded by “Bearer” to authorize them.
'Authorization': 'Bearer <access_token>'