Authentication
Getting authenticated as a developer
DIMO Check-in
Make sure you obtain a Developer License via the Console before authentication.
The Developer SDKs have functions related to authentication that can expedite the process. You can likely skip this step if you are using the SDKs.
Getting a JWT
Before you go through authentication with DIMO, there are 3 types of JWT as described below:
User JWT
A user JWT contains your Developer License as the audience
with the logged in user's account in the ethereum_address
field.
This JWT validates that the user is authenticated with DIMO.
14 days, user will need to re-authenticate again.
Utilize Login with DIMO on the frontend.
Developer JWT
A developer JWT contains your Developer License as both the audience
and the ethereum_address
.
This JWT validates you as the app registered with DIMO.
14 days, developers will re-authenticate again programmatically.
Utilize your Developer License on the backend.
Vehicle JWT
A secondary developer JWT to access vehicle private data. This JWT is specific to a vehicle (identified by token_id
) and an array of permissions granted by the user to the developer.
This JWT validates that your app has permissions to get vehicle data. This was previously called privilege_token
.
10 minutes, developers will trigger another exchange programmatically.
Use the Developer JWT on the Token Exchange API.
Authentication Format
DIMO uses Bearer Authentication format.
How it works
Authentication for DIMO works in 3 steps:
Generate Challenge: Generates a challenge and a state for a specific address.
Sign Challenge: To sign in to obtain a JSON Web Token to the API, the signer signs a cryptographic message, proving that they are the owner of the associated public key. This process is known as signing in with a digital signature.
Submit Challenge: The public key is then used to verify the user's digital signature and grant or deny access to the resources with the permissions set.
DIMO's implementation of the web3 signature mechanism for a backend application can be completed with the 3 steps below:
Step 1: Generate Challenge
POST
https://auth.dimo.zone/auth/web3/generate_challenge
Query Parameters
client_id
*
String
Configured client identifier, this is the 0x
client identifier received when you issue a Developer License.
domain
*
String
A valid redirect URI for the client, this is the domain
that you set when you configure a Developer License.
scope
*
String
Space-separated list of scopes, this needs to be openid email
response_type
*
String
This needs to be code
.
address
*
String
A hex-encoded, 0x-prefixed, 20-byte Ethereum address (case insensitive). This is the contract address of your Developer License as you are assuming the role of signer of the license. The value is essentially the same as the client_id
.
Step 2: Sign Challenge
You will need to format the challenge
string from Step 1 to hex and prefix it with 0x, combine that with an apiKey
obtained from the Developer Console, before signing the Ethereum transaction and obtaining a 65-byte signature.
To sign the challenge
, you will need to use a library in your preferred programming language to sign Ethereum transactions and messages with local private keys. We have provided a few language examples as a starter:
Step 3: Submit Challenge
POST
https://auth.dimo.zone/auth/web3/submit_challenge
Use x-www-form-urlencoded
for body parameters.
Request Body
client_id
*
String
Configured client identifier, this is the 0x
client identifier received when you issue a Developer License.
state
*
String
The state
string returned from Step 1.
grant_type
*
String
This needs to be authorization_code
.
domain
*
String
A valid redirect URI for the client, this is the domain
that you set when you configure a Developer License.
signature
*
String
The 0x-prefixed signature obtained from Step 2.
Developer Notes
If you made it this far, you should have an
access_token
that you can use to access some DIMO API endpoints. For protected API endpoints such as Telemetry API, a Vehicle JWT described in Token Exchange API is required.To use the
access_token
you received, please follow the Bearer Authentication Scheme to format your HTTP request headers. A typical format would look like{ "Authorization": "Bearer <access_token>"}
Last updated