shop-lockOAuth 2.0

Authenticate your apps with OAuth 2.0 to generate short-lived access tokens for vehicle and fleet APIs

Our OAuth 2.0 APIarrow-up-right with the client_credentials grant type allows you to create access tokens to manage your application resources. It's also possible for fleet solutions to use the REST API to retrieve vehicle data for any of their fleet vehicles. You can use the access tokens to authenticate with any of the following services:

We offer two different alternatives for creating an access token, both compliant with the OAuth2 standard.

You can choose the option that best fits your system design and software architecture.

Client ID & Client Secret

In order to get an access token, head to your application "OAUTH CLIENT" section in the console and copy the client_id and client_secret. Next you can make an API call to create a an access token:

curl --location 'https://sandbox.api.high-mobility.com/v1/access_tokens' \
--header 'Content-Type: application/json' \
--data '{"client_id": "a92cf969-e8ff-4ad4-a45f-42930edde12d", "client_secret": "xfVxR6xnlbeVHXkQatRx4FmxSJxFR0-M", "grant_type": "client_credentials"}'
{
    "access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTgwNzAwMDEsImlhdCI6MTY5ODA2OTcwMSwiaXNzIjoiaHR0cHM6Ly9zYW5kYm94LmFwaS5oaWdoLW1vYmlsaXR5LmNvbS92MS9hdXRoX3Rva2VucyIsInNjb3BlIjoiZmxlZXQ6Y2xlYXJhbmNlIHZlaGljbGU6ZWxpZ2liaWxpdHktY2hlY2sgdmVoaWNsZTpkYXRhIiwic3ViIjoiMjEwZmMyOTUtZDQ5OS00ZDgwLTk5MWUtZTQ3NTZlZDI3YTZmIiwidmVyIjoxfQ.2neMW6LioKvZYlbSTf-W4GwSHQmMr_8cyXfhyi4XJF-6F4HrvFNIsLlNUa93wp6BiJ_XEythR8DfWh0PrIaHrg",
    "expires_in": 300,
    "scope": "fleet:clearance vehicle:eligibility-check vehicle:data",
    "token_type": "bearer"
}

In this example you can see how the access token is included as the authorization bearer for retrieving the eligibility state of a vehicle.

The access token is valid for 5 minutes and can be used for any of the endpoints that are listed as the scope. The Token URI is listed in your application page in the console and differs between our sandbox and live data environments.

JWT-Based Client Assertion

In this type of authenticaion supports client auth using JWT assertions signed with asymmetric key pairs.

circle-info

WHEN TO USE?

While we recommand to use client_id and client_secret to authenticate, in some circumstances based on your requirements and internal policies you might want to use this approach.

The steps are as followed:

  1. Create a "OAuth Client Credentials" in the console for your application

  2. Sign a JWT with the required claims

  3. Call the /v1/access_tokens endpoint to get an access token. The parameter client_assertion_type must be included and set to urn:ietf:params:oauth:client-assertion-type:jwtbearer .

  4. Use the access_token value in the subsequent API calls.

The following snippet shows an example of how a JWT is generated using the private key, and how the access token is used for authentication in a subsequent API request.

OpenAPI Specification

You can see all endpoint specifications on the OpenAPI Reference page.

Last updated

Was this helpful?