This article provides a detailed overview of the Authorisation Code Grant Flow for integrating with the NowInfinity API, including step-by-step instructions, example requests, and error handling.
Authorisation Code Grant Flow is the preferred and most secure method to access the NowInfinity API. This flow ensures that sensitive credentials remain confidential and supports secure token exchange for accessing user data.
The Authorisation Code Grant Flow consists of the following steps:
Request Authorisation Code:
The client redirects the end-user to the NowInfinity authorisation server to request permission to access the user’s data.User Grants Permission:
Upon successful login, the user grants permission, and the authorisation server returns a unique code to the client via the redirect URI.Exchange Code for Token:
The client sends the authorisation code to the authorisation server to exchange it for a JWT security token.Access API:
The client uses the JWT token to access the NowInfinity API on behalf of the user.
Redirect the end-user to the NowInfinity authorisation server:
https://auth.nowinfinity-test.com.au/connect/authorizeQuery Parameters:
| Parameter | Description | Example Value |
|---|---|---|
client_id | Identifies your application | Provided by NowInfinity |
redirect_uri | URI to return the user after authentication | Determined by your application |
response_type | OAuth flow type (must be code) | code |
scope | Space-delimited list of requested scopes | api1 offline_access read write |
state | Optional CSRF token for request/response correlation | Unique GUID or identifier |
display | Optional: UI display mode (popup or omit) | popup (for popup UI), omit for normal page |
Example URL:
https://auth.nowinfinity-test.com.au/connect/authorize?client_id=my_client_id&redirect_uri=http%3A%2F%2Fmysite.com&response_type=code&scope=api1%20offline_access%20read%20writeIf all parameters are correct, the user will see a login form.
If incorrect credentials are provided, an error message will be displayed.
After login, the user is prompted to grant permission to your application.
Send a POST request to exchange the authorisation code for a JWT token:
https://auth.nowinfinity-test.com.au/connect/tokenForm Fields:
| Parameter | Description | Example Value |
|---|---|---|
grant_type | Purpose of request (must be authorization_code) | authorization_code |
client_id | Your application’s client ID | Provided by NowInfinity |
client_secret | Your application’s client secret | Provided by NowInfinity |
redirect_uri | Same redirect URI as in Step 1 | Same as Step 1 |
code | Authorisation code from Step 1 | Received from redirect |
Example Successful Response:
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6...",
"expires_in": 360,
"token_type": "Bearer",
"refresh_token": "222f4988703c8a36b8bcd4191b776063"
}Example Error Response:
{
"error": "invalid_grant"
}- Use the Authorisation Code Grant Flow for secure, server-side integrations with NowInfinity.
- Always keep your
client_secretconfidential. - Follow the step-by-step process for requesting and exchanging tokens.
If you need further assistance or integration support, please contact partners@class.com.au