Skip to content

Authenticate using Token

Authentication using Token

For token authentication, we are using Token based authentication system. You can make API requests over HTTP and authenticate using Token.

Note

Users who would like to access the resource over HTTP/API on their Frontend application, will at least has to have an account on the EngineerForce platform.

Let's assume you have two things here.

  1. A resouce that you would like to access is something similar to the following Endpoint.
  2. You have already generated the API Token with your accounts. (Please keep in mind that every token is depends on the creator account). The token will has full access as the creator account.

Example Endpoint

GET
/api/v2/users/me/

This route usually returns information related to the user who is currently making the Request

Example Request

http {{ENDPOINT}} Authorization:"API-Token {{YOUR_API_TOKEN}}"
curl GET -H "Authorization: API-Token {{YOUR_API_TOKEN}}" {{ENDPOINT}} 
let axios = require('axios');

let config = {
  method: 'get',
  url: '{{ENDPOINT}}',
  headers: {
    'Authorization': `API-Token {{YOUR_API_TOKEN}}` 
  }
};

axios(config)
  .then(res => {
    // ... response
  })
  .catch(e => {
    // ... error
  });
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
String credential = "API-Token " + {{YOUR_API_TOKEN}};
Request request = new Request.Builder()
  .url({{ENDPOINT}})
  .method("GET", body)
  .header("Authorzation", credential)
  .build();
Response response = client.newCall(request).execute();
import requests

url = {{ENDPOINT}}

payload={}
headers = {"Authorization": f"API-Token {{YOUR_API_TOKEN}}"}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)