ABRP OAuth2 API

Created with Sketch.

OAuth2 provides a means of authenticating users easily, and providing a secure and convenient way to identify and authenticate the user with Iternio. To set up OAuth2 with Iternio you will need an API key, and to provide us with a redirect URL and Application name. To get set up, send us an email at contact@iternio.com

Authorization Call

The first call made returns an HTML page on which the user can log in and approve the use of your application. If this HTML page is opened in the user’s default browser, their login may be cached and simplifies the process further.


KeyDatatypeComment
client_idintYour client ID, this avoids exposing your API key to the user. We will provide you this on request
redirect_uristringThis must match the redirect_uri we have on file for your ID.
response_typestringMust be set to "code" (defaults to this value if none set).
statestringThis is an optional field which adds a state value to the redirect URI and future returned token calls.

https://abetterrouteplanner.com/oauth/auth?client_id=<your_client_id>&response_type=code&redirect_uri=<your_redirect_uri>

Once the user approves the request you will receive the following at your redirect URI:


KeyComment
stateThe state string provided by the original Auth call.
auth_codeThe user's Authorization code. You can use this to retrieve the user's token.

https://your_redirect.uri?state=<state_provided>&auth_code=<returned_auth_code>

Token Retrieval Call

Once you have received an authorization code from the user, you can then retrieve the token. This token can be stored and reused as many times as needed. The following fields are needed to retrieve the user’s token:


KeyComment
grant_typeMust be "authorization_code" (Defaults to this value if none set).
client_idYour client ID
client_secretYour API Key
codeThe user's authorization code retrieved in the previous step
redirect_uriYour redirect URI, the user's token will be returned to this address.

https://abetterrouteplanner.com/oauth/token?client_id=<your_client_id>&client_secret=<your_api_key>&code=<auth_code>&redirect_uri=<your_redirect_uri>

This call returns a JSON object with the following items:


KeyComment
user_tokenThe user's token
token_typeBearer token, allows you to authenticate as the bearer.
stateState value input above in the auth call and associated with the token.

And that’s it! From here you can include the user’s token on calls to the various services we provide that need to identify or authenticate a user.