Connecting a vehicle
Select and connect the Jedlix Connect SDK
For easy integration, we strongly encourage you to use our Jedlix Connect SDKs
The SDK will handle all steps for you in the car connection process.
One car per user
The platform allows a single vehicle to be connected to a user account.
Using the Jedlix Connect API endpoints
If your application can not use the Jedlix Connect SDK, it is possible to use the Connect API endpoints directly.
Initiate a Connect Session
This will instantiate a web interface for the user to select and connect a vehicle.
curl --request POST \
--url https://demo-smartcharging.jedlix.com/api/v1/users/{USERID}/vehicles/connect-sessions \
--header 'Authorization: Bearer {USER_ACCESS_TOKEN}'
The API returns the connect session identifier, which you should use in further steps, and two essential web URLs:
startUrl
: The webpage hosting the Jedlix Connect web interface. This is where you should navigate your user to.redirectUrl
: The URL your app should wait for before closing the connect session and returning to your interface.
{
"vehicleId": null,
"isFinished": false,
"startUrl": "https://qa-assetsconnection.jedlix.com/web/start?sessionId=2714bd6e704940c4a7908a5a0f51b706",
"redirectUrl": "https://qa-assetsconnection.jedlix.com/web/end",
"id": "2714bd6e-7049-40c4-a790-8a5a0f51b706",
"redirectInfo": null
}
Checking if the session has finished
After reaching the.redirectUrl
, your app should check if the session has ended.
curl --request GET \
--url https://demo-smartcharging.jedlix.com/api/v1/users/{USER_ID}/connect-sessions/{CONNECT_SESSION_ID} \
--header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}'
In case the session is finished, the vehicleId
is returned and the value forisFinished
is set to True
.
After that, you may safely return to your interface, and the vehicle is connected to the user account.
{
"vehicleId": "16a30724-3e51-42b1-9ac1-b7fec24d5750",
"isFinished": true,
"startUrl": null,
"redirectUrl": null,
"id": "2714bd6e-7049-40c4-a790-8a5a0f51b706",
"redirectInfo": null
}
Vehicles with external authentication flows
For some car brands, an external authentication flow is required.
If this is the case, the vehicleId
is returned, but the value isFinished
is set to false.
The startUrl
and redirectUrl
are then updated with the web page the user should navigate next.
The redirectInfo
contains all the required information to complete the connection. The example below shows the connect session details for a Tesla vehicle. For this example above, the required information is the includeRedirectUrl
and tesla-auth.sid
Cookie.
{
"vehicleId": "16a30724-3e51-42b1-9ac1-b7fec24d5750",
"isFinished": false,
"startUrl": "https://auth.tesla.com/oauth2/v3/authorize?client_id=ownerapi&code_challenge=YTE0Nzc2N2VkYTFiM2ZjOGRjY2JmM2M2ZDFkM2FkNzYyNTJjNjM4YTk0OTBjYWY4N2U5OGI4NWU4ZDFlMDNkMw&code_challenge_method=S256&redirect_uri=https://auth.tesla.com/void/callback&response_type=code&scope=openid%20email%20offline_access&state=Ihd8-OpigiKcEtyenMtsuA&locale=en-US",
"redirectUrl": "https://auth.tesla.com/void/callback",
"id": "d4099dfb-dc0a-430b-afb0-8cfa671cf038",
"redirectInfo": {
"includeRedirectUrl": true,
"includeBody": false,
"includeCookies": [
"tesla-auth.sid"
]
}
}
Updating the connect session info with data from external webpage
After the redirectUrl
is reached (in this case <https://auth.tesla.com/void/callback?.....
>,
The data received during the process should be sent back.
curl --request POST \
--url https://demo-smartcharging.jedlix.com/api/v1/users/893a881e-3467-473f-8cb2-b1f8575502b1/connect-sessions/d4099dfb-dc0a-430b-afb0-8cfa671cf038/info \
--header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
--header 'Content-Type: application/json' \
--data '
{
"cookies": {
"tesla-auth.sid": "tesla-auth.sid\ts%3APf9M8iUtXAfqK8UTw1ybMW8Y2h2skkkA.Huks0E%2BRI3Z1VuFIp6IHma5T7bphayTLpR9abd4P5z4\tauth.tesla.com\t/\t08/09/2022, 16:07:15\t96 B\t✓\t✓\tLax"
},
"redirectUrl": "https://auth.tesla.com/void/callback?locale=en-US&code=SomeCode&state=xMqDOMxp1-hBp-nelC6pug&issuer=https%3A%2F%2Fauth.tesla.com%2Foauth2%2Fv3"
}
'
Which returns the following:
{
"vehicleId": "bf5316fc-15b3-4a79-8f66-0e002a1f9618",
"isFinished": false,
"startUrl": "https://qa-assetsconnection.jedlix.com/web/start-redirect?sessionId=5546bc849c164bc3a0b6bf73bea00ca2&redirectUrl=https://qa-assetsconnection.jedlix.com/web//web/choose-car-by-vin/tesla/080268da-363c-4c26-bfff-841d3fc842c9",
"redirectUrl": "https://qa-assetsconnection.jedlix.com/web/end",
"id": "5546bc84-9c16-4bc3-a0b6-bf73bea00ca2",
"redirectInfo": null
}
which tells your application to load the next URL in the browser and wait again for <https://qa-assetsconnection.jedlix.com/web/end
>.
After reaching that, again the connect session details are checked which now returns:
{
"vehicleId": "bf5316fc-15b3-4a79-8f66-0e002a1f9618",
"isFinished": true,
"startUrl": null,
"redirectUrl": null,
"id": "5546bc84-9c16-4bc3-a0b6-bf73bea00ca2",
"redirectInfo": null
}
This indicates that the session has finished.
Checking vehicle details
After the connect session has finished, vehicle details can be retrieved.
curl --request GET \
--url https://demo-smartcharging.jedlix.com/api/v1/users/{USER_ID}/vehicles \
--header 'Authorization: Bearer {YOUR_ACCESS_TOKEN}' \
The isConnected
flag indicates if it is connected & the isConnectable
flag indicates if the user can connect the car in case this has not happened yet.
Updated 11 months ago