The most up-to-date and relevant documentation about the subject is available here at the OfficeRnD Developer portal.
In this article, we'll cover how you can generate an OAuth 2 token and how long you can use it. Once you receive the token, you'll be able to use all of our publicly exposed endpoints.
Note: The OAuth2 tokens generated by OfficeRnD by default will expire in 3599 seconds, which is approximately 1 hour. You need to request a new token only after the old token expires.
How do I Create an Application in OfficeRND
The first step would be to Add an Application. You can do that by going to Settings > Data & Extensibility > Developer Tools > Applications tab. On this page, you'll see a list of all the applications that have been created.
When you're creating an application, you can specify a Name, Description, Image (if you upload one), and Permissions.
Permissions are the most important as they determine whether you'll be able to use the application to Read, Write, or both.
Once you create the application, you'll have two buttons next to it - Configure and View.
The Configure button allows you to change the parameters that you entered earlier.
The View button is very important as it gives you the Client ID and Client secret. These are two properties that you need in order to create the OAuth 2 token.
If you want to delete an app, please contact our support team.
How to Generate an OAuth 2 Token
Now that you have your Client ID and Client secret, you can make a call to our API in order to generate the token:
The URL you need to call to generate the token is https://identity.officernd.com/oauth/token.
The method that you need to use to generate the token is POST.
The content-type header must be set to application/x-www-form-urlencoded.
The body must contain the following fields:
client_id - taken from the OfficeRND application you just created.
client_secret- taken from the OfficeRND application you just created.
grant_type - currently, we only support "client_credentials," so the value is always going to be the same.
scope - here, you can specify whether you'd like the token to have permissions to read, write, or both, concatenated into a single string divided by a blank space, e.g., "officer.api.read officer.api.write".
Note: Please note that this will consider the permission you've specified for the application itself. For example, if the application has only "Read" permissions, you can't generate a token with "Write" permissions, and you will see an error.
If you're using Postman, see below:
After sending the POST request, you'll be able to see your token in the response body.
The property "expires_in" specifies the time in seconds for which you can use the token. All tokens are valid for 3600 seconds (1 hour).
{
"access_token": "<access_token>",
"token_type": "Bearer",
"expires_in": 3599,
"scope": "officernd.api.read officernd.api.write"
}
After you've generated the token, you can use it to authorize the different API endpoints.
Read next