The Token service is a compulsory
RESTful API for integrated users to retrieve a token which will be submitted as
part of the request header for authentication purposes. A valid token must be provided within each API
call. Tokens are only valid for 20 minutes. The Token API will be added by default to all
APPs created within the Fleetmatics Integration Manager.
Note: The returned response will
be restricted to the Reveal account's data plan. If the information being
queried is outside of the data plan, a "400 Bad Request error
"response will be returned.
For more details on your account's
data plan please reach out to Verizon Connect Customer Support
API Name |
Token API |
Endpoint |
|
Operation |
GET |
Operation and Path |
GET
https://fim.api.eu.fleetmatics.com/token/ HTTP/1.1 |
HOST |
fim.api.eu.fleetmatics.com
|
Accept |
text/plain |
Authorization |
Base64 encoded
value for the Integration Credentials.
Both the username and password should be combined into 1 field without
any spaces to generate the Base64 value. Note: The value must include “Basic” followed by the encoded value |
REVEAL API users will be
provided integration credentials to access the APIs. The integration
credentials are NOT the same credentials that will be used to access the
Fleetmatics Integration Manager. The
integration credentials will be linked specifically to one REVEAL account.
private static
string GetToken()
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://fim.api.eu.fleetmatics.com/token");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(
Encoding.ASCII.GetBytes(string.Format("{0}:{1}",
"<USERNAME>", "<PASSWORD>"))));
// New code:
try
{
// List data response.
HttpResponseMessage response = client.GetAsync(string.Empty).Result;
// Blocking call!
string token = null;
string message = null;
if (response.IsSuccessStatusCode)
{
token = response.Content.ReadAsStringAsync().Result;
message = token;
}
else
{
message = string.Format("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
}
Console.WriteLine(message);
Console.WriteLine("Press Enter to
continue:");
Console.ReadLine();
return token;
}
catch (Exception ex)
{
throw ex;
}
}
}