Enode
In order to register a vehicle through Enode, you need to:
- Retrieve authorization URL.
- Redirect user to the retrieved authorization URL and let user provide credentials.
- Register listener on a callback URL to receive an information when vehicle is successfully connected.
Prerequisites
Before starting registering vehicle, you need to fetch vehicle manufactureres that are currently enabled.
- API
- SDK
GET /v1/enode/vehicle-vendors?environment=:environment
X-Api-Key: <apiKey>
X-User-Id: <userId>
Query parameters
{
"environment": "<environment>"
}
environment- Enode environment (default value:PRODUCTION)
The list of supported environments:
type EnodeEnvironment = 'PRODUCTION' | 'SANDBOX';
PRODUCTION- production mode, requires users to use production credentials to add real vehicleSANDBOX- sandbox mode, allows users to generate dummy vehicles in Enode portal and connect them
client.getEnodeVehicleVendors(environment?: EnodeEnvironment, options?: Options);
Response
[
{
"displayName": "<displayName>",
"vendor": "<string>"
}
]
displayName- display name of the returned vendorvendor- value of the returned vendor (should be one ofVehicleManufacturer)
Step 1: Retrieve Authorization URL
- API
- SDK
POST /v1/enode/link
X-Api-Key: <apiKey>
X-User-Id: <userId>
Body parameters
{
"vendor": "<string>",
"redirectUri": "<string>",
"environment": "<string>"
}
vendor- vehicle manufacturer (should be one ofVehicleManufacturerreturned byGET /v1/enode/vehicle-vendorsendpoint)
The list of all supported vehicle manufacturers:
enum VehicleManufacturer {
BMW = 'BMW',
CITROEN = 'CITROEN',
CUPRA = 'CUPRA',
DACIA = 'DACIA',
DS = 'DS',
FORD = 'FORD',
HYUNDAI = 'HYUNDAI',
JAGUAR = 'JAGUAR',
JEEP = 'JEEP',
KIA = 'KIA',
LAND_ROVER = 'LANDROVER',
MG = 'MG',
MINI = 'MINI',
OPEL = 'OPEL',
PEUGEOT = 'PEUGEOT',
SKODA = 'SKODA',
TESLA = 'TESLA',
TOYOTA = 'TOYOTA',
VAUXHALL = 'VAUXHALL',
VOLKSWAGEN = 'VOLKSWAGEN',
VOLVO = 'VOLVO',
}
redirectUri- URL you want Enode to redirect back after vehicle was successfully connectedenvironment- Enode environment
Response
{
"linkUrl": "<string>",
"linkToken": "<string>"
}
linkUrl- URL to present Enode Link UI to your user via mobile in-app browsers or web redirectslinkToken- Token to initialize the Link SDK if you wish to present Link UI to your users via our mobile SDKs
Important note: Some vehicles require bluetooth pairing in order to be successfully connected and it is possible only with Link SDK usage, so we highly recommend using it instead of custom integration, otherwise there is a risk that a vehicle that requires bluetooth pairing will not be onboarded successfully. If you're using React Native with Expo, try this open-source Expo module: https://github.com/YoussefHenna/expo-enode-link-sdk.
client.getEnodeAuthorizationUrl(vendor: VehicleManufacturer, redirectUri: string, environment?: EnodeEnvironment, options?: Options);
Step 2: Redirect User to "linkUrl" or Pass "linkToken" to Link SDK (recommended)
Example authorization URL response:
{
"linkUrl": "<linkUrl>",
"linkToken": "<linkToken>"
}
Redirect User to Link URL
Redirect user to linkUrl it and let the user provide credentials.
Pass Link Token to Link SDK (recommended)
Below is the example with using Expo Enode Link SDK maintained by the community.
import * as LinkSDK from '@youssefhenna/expo-enode-link-sdk';
useEffect(() => {
const subscription = LinkSDK.listenToResult((resultCode, errorMessage) => {
switch (resultCode) {
case 'success':
console.log('Your account was linked successfully!');
break;
case 'cancelledByUser':
console.log('You cancelled the linking flow.');
break;
default:
console.log(`Linking failed: ${resultCode}, ${errorMessage}`);
break;
}
});
return () => {
subscription.remove();
};
}, []);
const startEnodeLink = () => {
LinkSDK.show('<linkToken>');
};
Step 3: Receive Authorization Code
In the first step, you provided redirectUri parameter Enode should redirect to after user successfully connects a vehicle.
Make sure you have this route defined in your system, so as soon as it's hit, you can trigger the call to get devices list.
Important note: Sometimes the system needs a couple seconds to receive connected device through webhooks, so if you don't see a new vehicle in the response from devices list immediately, we suggest to implement polling mechanism to make sure a new vehicle is properly retrieved.