Skip to main content

Obtaining an OAuth token

To use any Lime Direct REST APIs you need to obtain a token using your client id and secret by calling the Lime Authorization REST service.

The base url is https://authorize.lime.co/api

When calling any of the REST APIs you must include the API token in the Header of the REST call: -H "authorization: Bearer <API_TOKEN>"


Get the OAuth token

POST /v1/token

Returns the OAuth API key.

Response

Text response that is the API access token. Note this is not a JSON response.


Examples

There are several ways the API can be called:

CURL

curl -X POST 'https://authorize.lime.co/api/v1/token' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{ "clientId": "<YOUR_CLIENT_ID>", "clientSecret": "<YOUR_CLIENT_SECRET>"}'

Python

import http.client
conn = http.client.HTTPSConnection("authorize.lime.co")
payload = "{'client_id':'YOUR_CLIENT_ID'," \
"'client_secret':'YOUR_CLIENT_SECRET',"
headers = { 'content-type': "application/json" }
conn.request("POST", "/api/token", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

NodeJS

var request = require("request");
var options = { method: 'POST',
url: 'https://authorize.lime.co/api/v1/token',
headers: { 'content-type': 'application/json' },
body: '{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET"}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});

Java

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

Response response = new OkHttpClient.Builder().
build().newCall(
new Request.Builder()
.url("https://authorize.lime.co/api/v1/token")
.header("content-type", "application/json")
.post(new FormBody.Builder()
.add("client_id", "YOUR_CLIENT_ID")
.add("client_secret", "YOUR_CLIENT_SECRET")
.build())
.build()
).execute();
JSONParser parser = new JSONParser(JSONParser.DEFAULT_PERMISSIVE_MODE);
JSONObject jsonObject = (JSONObject) parser.parse(response.body().string());
System.out.println(jsonObject.toJSONString());