The goal of this guide is to authenticate the "Authorization code" grant type. This can be used to connect a CameraManager user with a third party system. First the user will login via the standard OAuth login page provided by Eagle Eye Networks CameraManager. Second, a refresh_token can be requested to prevent the user from logging in again. Refresh tokens should not be used in the browser, only in the partner's backend.
This guide assumes that the reader has basic knowledge of the following technologies:
1) Get your API key
Request your API key from https://dealer.cameramanager.com. The key will consist of 2 parts, an ID and a SECRET. For example, the ID can be "cameramanager.test" with the secret "qwertyuiopasdfghjklzxcvbnm12345".
2) Request login screen
Request the login screen via the following URL. You can request this via the browser. The {client_id} value should be the ID which is provided in the API key, always ensure that your SECRET remains private.
https://rest.cameramanager.com/oauth/authorize?scope=write&client_id={clientId}&response_type=code&redirect_uri={URI with http(s)://}
Note:
For example:
3) Login to login screen
When you are not logged in yet, the user will be presented with following screen. If the user has not authorized your application yet, he will be presented with following screen:
After login, the user is redirected to the redirect_uri with an additional "code" parameter. This code can later be used to get the access_token and refresh_token. The browser will be redirected to the following page: <redirect_uri>?code=AbCdEf.
For example: https://example.com/?code=AbCdEf.
5) Request customer tokens
With the CODE you can request an access_token and refresh_token with the following API call.
6) Get new access_token via refresh token
In case your access_token is expired you can login again using the credentials (email and password). However, this requires your user to login very often which is not user friendly. You can locally store the credentials but this is not recommended for security reasons, in this case you can store the refresh_token and use this to get a new access_token. This new access_token can be used again to use the API. The refresh_token will work until the user logs out.
7) Logout
To logout, perform the following API call which will delete the access_token and refresh_token. The API call must be performed as a DELETE HTTP request.