OAuth APIs¶
This section shows the Rest API end-points of OAuth Server.
Table of contents
Login¶
This API end point returns a token which should be added to the x-access-token header, for all other API requests.
- POST /auth/login¶
The
device_key
andcustomer_key
are obtained from the asvin dashboard. Thetimestamp
is unix epoch.Thedevice_signature
is HMAC-SHA256. The Device Signature section contains calculation details.- Request Headers
Content-Type – application/json
Example request:
$ curl --location --request POST 'https://oauth-server/auth/login' \ --header 'Content-Type: application/json' \ --data-raw '{ "device_key": "your-device-key", "timestamp": 1620045991 "device_signature": "your-device-signature" }'
var request = require('request'); var options = { 'method': 'POST', 'url': 'https://oauth-server/auth/login', 'headers': { 'Content-Type': 'application/json' }, body: JSON.stringify({"device_key":"your-device-key","timestamp": 1620045991,"device_signature":"your-device-signature"}) }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); });
import requests url = "https://oauth-server/auth/login" payload="{\"device_key\":\"your-device-key\",\"timestamp\":1620045991,\"device_signature\":\"your-device_signature\"}" headers = { 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)
<?php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://oauth-server/auth/login'); $request->setRequestMethod('POST'); $body = new http\Message\Body; $body->append('{ "device_key": "your-device-key", "timestamp": 1620045991, "device-signature": "your-device_signature", }'); $request->setBody($body); $request->setOptions(array()); $request->setHeaders(array( 'Content-Type' => 'application/json' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody();
Example response:
{ "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2MDYunDk4ODYsImV4cCI6MTYwNjMxMDQ4Nn0.CCWvzR124OGf5FFOFAObQDPNRlmtI_kaObtu0X-eNFpJUaHv5kfjfGzZl4PUVXTOidSC4SJXFLACqOgyY7gb1UiHI3S47KvhIdCLgte8BvEIyIWLLj4rD4mdWT4NeRkP67-AXUG9IVM7_6XaGB-xmVLD-cLKFimlH7wANeDxO51gOgbcO5CP-1LQKuc2ApYPnDwtJMbkLIcQ-f7k81ouiiOWKOsB-cXq8yqt85WV4BJADhTDbvm3kjAQ5AEOpi7cU_sxh4JG4RaFKz7mNAanvHTw7LbZmP6tcvcf-bvcqTkkb0nkstXCD6300mBe4D44gY-7OehM1HF7xUS6nYpnIw" }
- Response Headers
Content-Type – application/json
X-RateLimit-Limit – 10
X-RateLimit-Remaining – 9
X-RateLimit-Reset – 1617352926
- Status Codes
200 OK – OK
429 Too Many Requests – Too many requests in this time frame.
500 Internal Server Error – Error on Server