Skip to main content
The connect function is used to authenticate with Smokeball and generate a token session for your application. The token session provides access to short-lived access tokens that can be used to make API requests to the Smokeball API with the scopes you have configured in your Smokeball App.

Prerequisites

1. Initialize the SDK

Before using the connect function, you must initialize the SDK.

2. Obtain an Embed Token from your Backend

Your backend will receive an embed token from Smokeball (for example, through a plugin pre-flight request). This embed token:
  • Has a lifetime of 1 minute
  • Is tied to the logged-in user ID
  • Is tied to your integrating app’s Client ID
Your backend should provide this token to your client application.

Using the Connect function

Only applications that have been configured and approved by Smokeball are able to use the connect function. Once you have:
  1. Initialized the SDK
  2. Obtained an embed token from your backend
You can call the connect function:
The connect function accepts a request object with the following structure:

Response

The connect function returns a token session that exposes a token() function. This token session:
  • Lasts for 1 day regardless of refresh token lifetime, requiring a new session to be generated everytime your app is loaded
  • Provides access to short-lived tokens scoped to your app’s Client ID and configured scopes
The token session object has the following structure:

Getting Access Tokens

Use the token() function from the token session to acquire a new short-lived access token:
The refresh token and refresh functionality are handled automatically by the SDK backend. You do not need to manage refresh tokens directly.

Complete Example

Notes

  • The embed token is provided to your backend by Smokeball - typically via a secure pre-flight request, or similar integration flow. Your backend is responsible for securely receiving and passing this token to your client for SDK authentication.
  • The embed token is valid for only 1 minute and can be used a single time. Be sure to use it immediately after receiving it, as it will expire quickly and cannot be reused.
  • The token session created by connect lasts for exactly 1 day, after which you must generate a new session.
  • Access tokens obtained via token() are short-lived and scoped to your app’s Client ID and configured scopes.