OAuth Client

Creating an OAuth client generates a Client ID (client_id) and Secret Key (client_secret) which are then used to generate access tokens for Nitro APIs. You can view the Secret Key for any OAuth Client you create. Secret Keys belonging to other users are hidden.

All Nitro Studio functionality that requires a token, except data import, will use the default OAuth Client. The default Client (studio) is created the first time you use a feature that requires it. Data import requires an OAuth Client named batch-import that uses the batch_import scope.

Token Management Best Practices

When using web components and blocks, Bunchball recommends that you create a minimum of two OAuth clients:

A new token should not be requested with each user session. Your code should 1) request a token, 2) listen for a 401 https code indicating the token is invalid, and then 3) request a new token when you receive the expiration message.

Create an OAuth Client

OAuth runs through the API Gateway and does not require or support whitelisting. They do not work together.

  1. Open Nitro Studio > Configuration > OAuth.
  2. Click New Client.
  3. In the Name field, enter a descriptive name.
    Typically, the name identifies what you are using the OAuth client for.
  4. If necessary, enter a Redirect Url.
    The Redirect URL is used to set up a specific type of authorization that is not required by Nitro.
  5. In the Scopes field, select the access you needClosed.
  1. In the Duration (minutes) field, set the amount of time a user can access the feature using this token in one session.
  2. In the Maximum Duration Per Day (minutes) field, set the amount of time a user can access the feature using this token in one day.

Note: The default timezone for all duration based tokens is Eastern Standard Time (EST). Although you can define token duration for user access, this is not a recommended feature for all programs as it can limit effectiveness. A duration can be used where strict limitations are needed for compliance.

  1. Click Save.

Generate an OAuth Access Token

In your app, include the code to generate an OAuth token. A token is typically generated at user login. Use the client_secret and client_id from your OAuth client to acquire the token. The Client Id and Secret Key are available on the Site Settings > OAuth tab. Note: This code should not be visible to a browser.

When you request an access token without passing a user ID, you get a 2-legged token. This is typically reserved for administrative scenarios such as updating your groups. When your token request includes a user ID, you get a 3-legged token. This is necessary for a user centric experience like web components and blocks.

Access tokens with a gamification_user scope require a 3-legged token and tokens with a global scope require a 2-legged token. Access will be denied if the token does not meeting the security requirements.

OAuth Request Example

Would be used as:

Copy
{
  "token_type": "bearer",
  "access_token": "5a2ccdee047515c1a8",
  "expires_in": 86400
}

See also

RESTFul APIs

Site settings