Production Token Request

🚧

Oauth Token Request API have been deprecated. Please use the API Key instead.

Oauth Token Request

You must request the token from OAuth as follows. You will need to provide

  • client_id
  • client_secret

These can be obtained via the eDRV Dashboard > API page.

request(options, function (error, response, body) {
  if (error) throw new Error(error);
  let access_token = body.access_token;
  console.log(access_token);
});
const request = require('request');

const options = {
  method: 'POST',
  url: 'https://auth.edrv.io/oauth/token',
  headers: {
    'content-type': 'application/x-www-form-urlencoded',
  },
  form: {
    grant_type: 'client_credentials',
    client_id: 'S4BTj2Kx8Oe75y64J2QeQ2j2oR1CeDRV',
    client_secret:
      'kLaqFRcvB8AbvRVa1pOgFkkO3j_abeN9D2sf2w79Z4Hb2URfdcNybpRigak0de',
    audience: 'https://api.edrv.io',
  },
  json: true
};

request(options, function (error, response, body) {
  if (error) { throw new Error(error) }
  else {
    let { access_token, expires_in } = body;
    console.log(access_token);
    console.log(`Token expires in:${expires_in} seconds`);
  }
});
{
    "access_token": "YOUR_ACCESS_TOKEN",
    "expires_in": 86400,
    "token_type": "Bearer",
    "scope": "read:x write:y",
}

Please grab the "access_token" above and set it within your application. You will use it to authenticate all API calls to eDRV.

❗️

Excessive Token Requests

Once you have created a token, your application must save it. Only request a new token if it is about to expire (see expires_in key).

Token Expiry

The eDRV token is automatically set to expire. The expiry time (in seconds) is included in the response via the expires_in key.

Once the token is expired, all the API's calls will return the following response with http status code 401[Unauthorized].

{
    "ok": false,
    "message": "jwt expired",
    "result": null
}

Your application should request a new token from eDRV, refer to the Oauth Token Request section in this page for creating a new oauth token request.

❗️

Never give your Access Token to a third party

Your Access Token can give access to your private Charge Station data and should be treated like a password.


What’s Next

Use your access_token to authorize all eDRV API requests