Vernon Browser uses the OAuth 2.0 protocol to secure incoming API requests from clients. Currently, only the authorization code grant type is supported. Every incoming API request requires an access token to be included in the HTTP request headers (authorization header) in the following form:
Authorization Bearer <your access token>
e.g. Authorization Bearer some.access.token
The client ID & client secret credentials are required to generate the access token. Both these credentials are generated when an API Key is created in Vernon Browser.
clientId
- A unique code that identifies a client and is used when requesting an authorization code.
clientSecret
- A secret for the client and when used along with authorization code can generate an access token.
The client secret should not be made public and if compromised the API Key must be revoked in Vernon Browser.
The authorization flow using the OAuth 2.0 authorization code grant type is a two-step process. The steps involve getting an authorization code and then exchanging the authorization code for an access token which subsequently can be used for making API requests.
Send a request to following API endpoint to get the authorization code:
GET /api/v3/oauth/authorize
The following query parameters must be included while making this request:
clientId=<your client ID>
responseType=code
redirectURI=<your registered redirect URI>
state=<any random alphanumeric value>
codeChallengeMethod=S256
or codeChallengeMethod=PLAIN
codeChallenge=<calculated alphanumeric value>
f9752bd2-4346-439c-b14b-0c870b48ca82
is f9752bd2-4346-439c-b14b-0c870b48ca82
f9752bd2-4346-439c-b14b-0c870b48ca82
is xnD-u3lQbKrV5sWVLtiVXZuv3Z32uwmrVd411_IsXT8=
GET /api/v3/oauth/authorize?clientId=<your client ID>&responseType=code&redirectURI=<your registered redirect URI>&state=<any random alphanumeric value>&codeChallengeMethod=S256&codeChallenge=<calculated aphanumeric value>
If the request is valid Vernon Browser will return a 302 response with the redirect URI, authorization code & state in the HTTP Location response header.
Vernon Browser will return a bad request response (application/json) if any of the query parameters are not as expected.
The authorization code & state will be passed as query parameters to the redirect URI. Use the authorization code as quickly possible as it is a very short-lived token.
302 https://<your.redirect.uri>?state=<state value sent in request>&code=<authorisation code>
Ensure the value of state returned from response matches the state that was originally sent while making the request. If they don't ignore the authorization code.
Once the client has the authorization code it can exchange it along with the client secret for an access token. Send a request to following API endpoint to get the authorization code:
POST [application/json] /api/v3/oauth/token
The following parameters must be included in the request body (application/json) while making this request:
code: <authorization code>
grantType: code
redirectURI: <your registered redirect URI>
clientId: <your client ID>
clientSecret: <your client secret>
codeVerifier: <authorization code>
Example
POST /api/v3/oauth/token
{
"code": "<authorization code received in step 1>",
"grantType": "code",
"redirectURI": "<your registered redirect URI>",
"clientId": "<your client ID>",
"clientSecret": "<your client secret>",
"codeVerifier": "<code verifier generated in step 1>"
}
If the parameters passed as part of the request body are as expected the server will issue the access token. Vernon Browser will throw a bad request if it fails to validate the credentials. The response from the server will always be in application/json format. The expiry in seconds for the access token is included as part of the response.
Example
{
"accessToken": "<access token>",
"tokenType": "bearer",
"expires": "<expiry in seconds>",
}
Vernon Browser currently supports an easier form of authorization for clients who cannot use the OAuth 2.0. This is turned off by default and if you wish to use it contact us at vsl@vernonsystems.com and we can share the basic key.
Though the basic token is easier to implement, the trade-off is it is less secure and every API request requires additional validation which increases the response time. The increased response time might be acceptable in some cases if the client is harvesting the data rather than looking it up real-time from the client application.
Authorization Basic <your basic key>
e.g. Authorization Basic some.basic.key
The basic key never expires and if compromised must be revoked in Vernon Browser.