Generate and save your API Key and add at least one Redirect URI of your choice.
Using the Data SDKs
1
Install the SDK
npm install @dimo-network/data-sdk
# Or install with yarn
yarn add @dimo-network/data-sdk
pip install dimo-python-sdk
# Windows users:
Install-Package Dimo.Client
# Mac/ Linux users:
dotnet add package Dimo.Client
2
Import + Initiate the SDK
Import the SDK:
# ES Modules:
import { DIMO } from '@dimo-network/data-sdk';
# Or Common JS
const { DIMO } = require('@dimo-network/data-sdk/dist/index.cjs';
Initiate the SDK depending on the environment of your interest. We currently support both Production and Dev environments, but recommend using Production at this time.
const dimo = new DIMO('Production');
# or
const dimo = new DIMO('Dev');
Import the SDK:
from dimo import DIMO
Initiate the SDK depending on the environment of your interest. We currently support both Production and Dev environments, but recommend using Production at this time.
using Dimo.Client;
var dimoClient = new DimoClientBuilder().AddAllServices().Build();
With Dependency Injection:
using Dimo.Client;
services.AddDimoClient(options =>
{
options.Environment = DimoEnvironment.Production;
});
3
Perform Auth Function Calls
Use the credentials from your Developer Console application (Step 1) to obtain a Developer JWT, and a Vehicle JWT for vehicle tokenIds that have shared privileged vehicle access with you. You can learn more about these in Authentication.
The domain value is any of the configured redirectUri's you've added in the console.
The private_key value is the API Key you generated.
Get Developer JWT
const developerJwt = await dimo.auth.getToken({
client_id: '<client_id>',
domain: '<redirect_uri>',
private_key: '<api_key>',
});
// The TS/JS data SDK references the "access_token" and formats it
// in the format you need in later steps
auth_header = dimo.auth.get_token(
client_id = '<client_id>',
domain = '<redirect_uri>',
private_key = '<api_key>'
)
# Store the Developer JWT from the auth_header dictionary
dev_jwt = auth_header["access_token"]
var auth = await dimoClient.AuthenticationService.GetTokenAsync(
clientId: "<your client id>",
domain: "<your domain>",
privateKey: "<your private key>",
address: "<your address>" // This value is the same as clientId
);
Console.WriteLine(auth.AccessToken);
# Call to get a Vehicle JWT
get_vehicle_jwt = dimo.token_exchange.exchange(
developer_jwt = dev_jwt,
token_id=<token_id>
)
# Store the Vehicle JWT from the get_vehicle_jwt response
vehicle_jwt = get_vehicle_jwt['token']
var vehicleTokenId = 123456; // The token id of the vehicle
var vehicleJwt = await dimoClient.TokenExchangeService.GetPrivilegeTokenAsync(
accessToken: auth.AccessToken,
tokenId: vehicleTokenId,
privileges: [
PrivilegeSharing.AllTimeNoLocationData,
PrivilegeSharing.Commands,
PrivilegeSharing.CurrentLocation,
PrivilegeSharing.AllTimeLocation
]); // The privileges you want to get for the vehicle