Skip to main content

Authentication Use Case

How do I Authenticate?

The Client API uses OAuth 2.0 for authentication. You can read more about OAuth 2.0 here. The Client API also uses the Client Credentials Grant to authenticate and the JSON Web Token (JWT) for the access token. You can read more about JWT here.

To request an access token, you will need to send a POST request to the following URL: https://api.receeve-demo.com/v1/oauth2/token

When doing this, be sure to include the Authorization header with the Basic authentication scheme and the client_id and client_secret as the credentials. The client_id and client_secret are provided by receeve.

Below is an example: Given the client_id: 4a1vn6k4ac4hp5uu3q2qv55555 and client_secret: 1195uiv9sub4gkcgdl8tioe209lvcmvivu55b1ef60r7lhXXXXXX applying the Basic authentication scheme, the Authorization header will be: NGExdm42azRhYzRocDV1dTNxMnF2NTU1NTU6MTE5NXVpdjlzdWI0Z2tjZ2RsOHRpb2UyMDlsdmNtdml2dTU1YjFlZjYwcjdsaFhYWFhYWA==

POST /v1/oauth2/token HTTP/1.1
Host: api.receeve-demo.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic NGExdm42azRhYzRocDV1dTNxMnF2NTU1NTU6MTE5NXVpdjlzdWI0Z2tjZ2RsOHRpb2UyMDlsdmNtdml2dTU1YjFlZjYwcjdsaFhYWFhYWA==

NGExdm42azRhYzRocDV1dTNxMnF2NTU1NTU6MTE5NXVpdjlzdWI0Z2tjZ2RsOHRpb2UyMDlsdmNtdml2dTU1YjFlZjYwcjdsaFhYWFhYWA==

The answer to that request will be a JSON similar to this:

{
"access_token": "eyJraWQiOiJLMlJOeGR3RGJJT3R5SXQ2cVFxalhJU3dcL0FxZ0k2a2xCbkx1RHgzaHlscz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI0YTF2bjZrNGFjNGhwNXV1M3EycXZ1NGNnYyIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoiZGVmYXVsdFwvRGVmYXVsdCIsImF1dGhfdGltZSI6MTY4MDc3MTU5NywiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLmV1LWNlbnRyYWwtMS5hbWF6b25hd3MuY29tXC9ldS1jZW50cmFsLTFfTzZVSjF6VHg1IiwiZXhwIjoxNjgwNzc1MTk3LCJpYXQiOjE2ODA3NzE1OTcsInZlcnNpb24iOjIsImp0aSI6ImIwYzk2MThmLWVkYjYtNDMxNS04ZDAyLTEzYjg2MzQyNWYwMyIsImNsaWVudF9pZCI6IjRhMXZuNms0YWM0aHA1dXUzcTJxdnU0Y2djIn0.FJTJbvKqDHc_Q2o4CHpTYCsim-snv1sQmld9T0DlXJsDOP5IVFFB_sSsuYl0DLfp1PEBc-r75oHmGrrL4en-uq104pW9t4D-4Byye78NzAm2DTRc1H9bF3M8_9V-ZEvttPnPP1qlbqLxSEBPPSJ69eXCs6v5ScPQRKqKxfqCnuCoJuWX-Jd5eM8oocdqObFTtRiLdoQs5Sa8xi-OEMGMrQBkxXW3kk-tKWtovSRoA6UsLRZG3_UK7sl7wE3Wl5qA2gl_PNIXTTFsR9WLbDpqIC8grctz2ayTmAaaR7538FesJFySzglVD0iNZiNbcPbIK4mNi1gaw18Av1uQ_mu3vw",
"expires_in": 3600,
"token_type": "Bearer"
}

Note: You can use the same token for multiple requests as it remains active for some time. If you need another token after it expires, feel free to request another one.

FAQ

  • How do I create the token for the Basic Authentication Scheme? Here is an example used to create the Authorization header in Javascript:
const clientId = "4a1vn6k4ac4hp5uu3q2qv55555";
const clientSecret = "1195uiv9sub4gkcgdl8tioe209lvcmvivu55b1ef60r7lhXXXXXX";

const token = Buffer.from(`${clientId}:${clientSecret}`).toString("base64");