This project should give you an overview of how to implement High Mobility's OAuth and the HMKit library for working with car data. It consists of two pages: a login page to start the authentication flow, and a dashboard which displays the car's diagnostics state and lets you toggle the door locks.
- Node v8.9.0+
- High mobility developer user account
- Vehicle (with diagnostics and door locks capabilities)
- Cloud app (with diagnostics and door locks permissions)
Clone the project
git clone https://github.com/highmobility/hm-node-auto-api-explorer.git
Open your cloned project folder
cd hm-node-auto-api-explorer
Install dependencies
npm install
Create a .env config file based on .env.example
cp .env.example .env
You need to configure all 7 missing variables. To do so, log in to the High Mobility developer center. Firstly, you need a cloud app and a vehicle which are linked. The vehicle needs to support diagnostics and door locks capabilities, and the app needs to have permissions for them.
HM_APP_ID
- This is displayed on your cloud app's page and is labelled "Serial #". If you do not have a cloud app, create a new one and link it to your vehicle.HM_CLIENT_CERTIFICATE
andHM_CLIENT_PRIVATE_KEY
are also displayed at your cloud app's page. You can see Node and REST snippets if you navigate to CLIENT CERITFICATE tab. The certificate and private key that we need are used in Node snippet as HMKit constructor parameters. The first parameter is the client certificate and the second parameter is the private key.OAUTH_CLIENT_ID
,OAUTH_CLIENT_SECRET
,OAUTH_AUTH_URI
andOAUTH_TOKEN_URI
can be found at Team Settings (top right corner dropdown menu) > OAuth Client. Before leaving this page, you also need to configureREDIRECT URI
. You can find the input at the bottom of the page - set it tohttp://localhost:3000/auth/oauth-callback
.
!! Do not forget to launch your vehicle's emulator in the developer center before running the server. After you have launched the emulator, run the app with this command:
npm start
Open http://localhost:3000
in your browser.
If you have questions or would like to send us feedback, join our Slack Channel or email us at [email protected].