To make requests to the Smartcar API, you first need to obtain an access token. This guide walks you through the process of getting the authorization code and exchanging it for an access token for the first time.Documentation Index
Fetch the complete documentation index at: https://smartcar.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
1. Launch Smartcar Connect
Direct your user to the Smartcar Connect URL. The user will:
- Select their vehicle brand
- Log in with their connected services account
- Approve the requested permissions
redirect_uri with an authorization code as a query parameter.2. Handle the Redirect and Extract the Code
Your application should listen for requests to the
redirect_uri. When Smartcar redirects the user, extract the code parameter from the query string.
Example redirect:3. Exchange the Code for an Access Token
Use the authorization code to request an access token and refresh token from Smartcar’s OAuth token endpoint.Here is an example using the Smartcar Node.js SDK:The returned
tokens object includes accessToken and refreshToken strings, plus expiration and refreshExpiration as Date objects. Store these securely in your backend database.
The access token expires after two hours, and the refresh token expires after 60 days.
