🢐  Back

Locate2u REST API

In order to integrate/use Locate2u API, there are several steps to be done :

  1. Generate your client id and client secret
  2. Get access token from Locate2u identity server via HTTP Post
  3. Use access token to call Locate2u APIs

1. Generate Client Id and Client Secret

Guide on how to generate your client id and client secret can be foundĀ here.

2. Get Access Token

Locate2u uses OAuth 2.0 client credential grant to authenticate API requests.

OAuth is an open standard authorization protocol and framework that safely allow authenticated access to assets without actually sharing the initial, related, single logon credential.

In order to generate the token, you will need to use HTTP Post to url below :


And provide body with x-www-form-urlencoded such as :

  1. client_id = [YOUR_CLIENT_ID]
  2. client_secret = [YOUR_CLIENT_SECRET]
  3. grant_type = “client_credentials”
  4. scope = “locate2u.api”

Sample code :

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Locate2u_api_project
public class Program
public static async Task<string> getToken()
using (HttpClient client = new HttpClient())

var values = new Dictionary<string, string>
{"client_id", [YOUR_CLIENT_ID]},
{"client_secret", [YOUR_CLIENT_SECRET]},
{"grant_type", "client_credentials"},
{"scope", "locate2u.api"}

var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://id.locate2u.com/connect/token", content);
string returnValue = await response.Content.ReadAsStringAsync();
var token = JsonConvert.DeserializeObject<Token>(returnValue);

return token.access_token;
catch (Exception x)

return null;



3. Use Access Token to Call Locate2u APIs

After we got the access token, we can call Locate2u API by doing HTTP GET/POST.

You can see all of the API documentation here and how to test it out here.

Sample code for getting user information :

public static async Task<GetUser> getUser()
using (HttpClient client = new HttpClient())
Console.WriteLine("[START] - Getting User");

GetUser user = null;

var token = await getToken();
client.BaseAddress = new Uri(Variables.baseUrl);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Add("User-Agent", "PostmanRuntime/7.26.8");
var response = await client.GetAsync("users/me");


if (response.IsSuccessStatusCode)
user = await response.Content.ReadAsAsync<GetUser>();
Console.WriteLine("[END] Token successfully requested");

return user;

catch (Exception e)
Console.WriteLine("Error : " + e);

return null;



//Get User API Models :

public class GetUser
public string FirstName { get; set; }
public string LastName { get; set; }
public string Company { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string VehicleType { get; set; }
public string TimeZone { get; set; }
public string CountryCode { get; set; }
public string Bio { get; set; }
public string Industry { get; set; }
public string WebsiteUrl { get; set; }
public string Role { get; set; }
public string RegionCode { get; set; }
public string Status { get; set; }