There are 3 main steps to integrate Smartcar into your application to make API requests to vehicles:
- Launch Connect to get consent from the vehicle owner
- Fetch an access token
- Make a request to the vehicle
The architecture that’s right for you
Smartcar Connect is Smartcar’s OAuth 2.0 authorization flow. It is your users’ first and only touchpoint with Smartcar. After a user enters the Smartcar Connect flow and authorizes their vehicle(s), your application is able to make requests to the Smartcar API. Those requests allow your application to retrieve information and send commands to the user’s vehicle(s), such as reading the odometer and unlocking the doors.
Depending on your web or mobile application architecture, you can implement the Smartcar Connect flow in different ways.
Server-side Rendered Application
User launches Connect
Using the Smartcar iOS SDK or the Smartcar Android SDK, your application launches Smartcar Connect in a browser view. The user logs in with the username and password of their vehicle’s connected services account and grants your application access to their vehicle.
User logs in to their vehicle's connected services account
The browser view gets redirected to a special custom-scheme
REDIRECT_URI. For more details on how to configure a custom-scheme
REDIRECT_URI, see our API reference.
Smartcar redirects the user back to your application
Once the user has completed the Smartcar Connect flow, the completion handler in the iOS or Android SDK is invoked with the authorization code.
Call your back-end service
Your mobile application sends the authorization
code to its back-end service.
Fetch your first tokens
In order to exchange the authorization
code for an
ACCESS_TOKEN, your application makes a request to the Smartcar API. This request must contain the authorization code along with your application’s
Store your tokens
In response, Smartcar returns an
ACCESS_TOKEN and a
REFRESH_TOKEN. These should be stored in your application’s database.
Make an API request
ACCESS_TOKEN, your application can now make API requests to the user’s vehicle.
Let’s get building
Now you have an idea of how Smartcar works, take a look at one of our Getting Started guides in the tutorials section to get connected to a vehicle.