Android
Introduction
Smartcar is an API that allows mobile and web applications to communicate with vehicles across brands (think “check odometer” or “unlock doors.”). This tutorial will help you get up and running with the Smartcar API.
In this tutorial, we will use the Android SDK to create an Android application that displays your car’s information.
How Smartcar works with mobile applications
- The Mobile Application launches a Chrome Custom Tab with Smartcar Connect to request access to a user’s vehicle. It does so using the Smartcar iOS or Android SDK. On Connect, the user logs in with their vehicle credentials and grants the Application access to their vehicle.
- The Chrome Tab is redirected to a specified
redirect_uri
along with an authorizationcode
. This will be the custom scheme set on the application. The Smartcar iOS or Android SDK receives the authorization in a view listening for the specified custom scheme URI, and passes it to the Mobile Application. - The Mobile Application sends the received authorization
code
to the Application’s back-end service. - The Application sends a request to the Smartcar API. This request contains the authorization
code
along with the Application’s client id and client secret. - In response, Smartcar returns an
access_token
and arefresh_token
. - Using the
access_token
, the Application can now send requests to the Smartcar API. It can access protected resources and send commands from and to the user’s vehicle, such as retrieve the location and unlock the doors.
How this tutorial is structured
Follow along with our integration tutorial to build our simple web application.
This tutorial is split into three sections:
- Setup - Set up your environment to develop on Smartcar
- Authorization flow - Learn about Smartcar Connect and how to get an authorization
code
- Send a request - Learn how to exchange an authorization
code
for anaccess_token
required to send a request to Smartcar
Let’s get building!