Token Exchange API
Gateway to obtaining a JWT to access protected API services.
Developer Notes
New to authentication on DIMO? Check out the Authentication Explainer here, or check out our video on how the different JSON Web Tokens (JWTs) work.
Overview
This is a private API endpoint for developers on the DIMO Network. It handles the exchange to obtain a Vehicle JWT. When users shared permissions with an app, the app can now request for vehicle data on behalf of the users.Base URL
https://token-exchange-api.dimo.zone
Endpoints
Create a token exchange
Creates a token exchange to obtain a Vehicle JWT. The response will provide a short-lived token that last you 10 minutes to access additional vehicle information such as Trips and Telemetry data.Parameters
nftContractAddress
stringRequiredThe Vehicle NFT address, in the Production environment, this is: 0xbA5738a18d83D41847dfFbDC6101d37C69c9B0cF. If you're using any of the SDKs, this is set for you when you initialize a DIMO instance in production.
privileges
[integer]RequiredAn array of integers indicating the level of privileges provided to the token bearer. While this parameter is required when making direct calls to the API, the latest versions of the Data SDKs can handle this for you. See the examples to the right for more information.
tokenId
integerRequiredThe Vehicle ID that you are requesting permission to. This is an integer that indicates the vehicle you are inquiring about.
POST/v1/tokens/exchange
const vehicleJwt = await dimo.tokenExchange.exchange({developerJwt: "eyJhbGc...ILlujqw",tokenId: 123456})
Response
{"token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjJmMGM3NTc5ZmYyYTAzMGY0NmY1YzVkMzMyY2YyYjMyMzkxMzIxZGIifQ.eyJjb250cmFjdF9hZGRyZXNzIjoiMHhiYTU3MzhhMThkODNkNDE4NDdkZmZiZGM2MTAxZDM3YzY5YzliMGNmIiwiZXhwIjoxNzA2MDM4MTI4LCJpYXQiOjE3MDYwMzc1MjgsImlzcyI6Imh0dHBzOi8vYXV0aC1yb2xlcy1yaWdodHMuZGltby56b25lIiwicHJpdmlsZWdlX2lkcyI6WzRdLCJzdWIiOiIweGJBNTczOGExOGQ4M0Q0MTg0N2RmRmJEQzYxMDFkMzdDNjljOUIwY0YvMjE5NTciLCJ0b2tlbl9pZCI6IjIxOTU3In0.0J3HIsNeG5-JvMBcTwR8KHhTnXb31jvwjxiKVRnNaFidE0vLbyd6PtPsouniZQMIC46wzqwm2c7aZ61WhPIx9p5TB-cKcMmeKFE9mFZfBuSmvNbDd5icAvkxogWlNPki5WM2_otaGf9WtsZPlWW9GgUmBoPaRhiKB3fX7TPROcn0tTjtVir9HJKnf2CMkDwTk9rZxer8eGB6ekBSJr1aDjdqlY6HRxF_azy_rWVdzB1Wd1He9KyB3HHr1qBk5XK8d_zTA-4X3i3IEP5Z8Q3gxgoQRem70SnBNpjJjeRgAgzjfqHnKaFcjhKlxWD0h9mnpGWvd3oZLd9BPqR3WyDUCA"}