Xkit

The xkit Developer Hub

Welcome to the xkit developer hub. You'll find comprehensive guides and documentation to help you start working with xkit as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Retrieving tokens from a Client

Retrieving 3rd Party Application Access Tokens from a Client

If you're writing a client (e.g. Javascript) that needs access tokens for 3rd Party applications, you can retrieve them using the Platform User API.

Since you'll be operating in the context of a single user, you will only be able to retrieve the access tokens of the currently logged in user.

It's recommended that you use xkit.js to access the Platform User API as it manages authentication for you beyond getting the user token

Using xkit.js

xkit.js is a browser-based Javascript library for working with the Xkit Platform User API. You can install this library, customized to your application with the following script tag:

<script src="https://<your-slug>.xkit.co/xkit.js"></script>

xkit.js exposes 3 methods to retrieve a logged-in user's connections:

  • getConnection is a direct call to the Get User Connection endpoint.
  • getConnectionOrConnector will always return a connection-like object, as it will fall back to the Connector endpoint if a user has not set up a Connection.
  • getConnectionToken returns a token if it is available, and null otherwise.

It's recommended that you use the getConnectionToken method for the easiest experience. If the connection exists and is available, a token will be returned to you. Otherwise it won't , and you should send the user to the Xkit Catalog to create or repair the connection.

You can use the getConnectorUrl method on xkit.js to find the URL to send the user to in order to create or repair a connection.

A sample usage of these functions is below:

xkit.ready(async () => {
  await xkit.login("your_user_token")
  
  const slackToken = await xkit.getConnectionToken("slack")
  
  if (!slackToken) {
    window.location.href = xkit.connectorUrl("slack")
  }
  
  // ... do something with the Slack API
})

Using the Platform User API

You can also use the Platform User API directly to retrieve a user's connection (and accompanying access_token) using the Get User Connection endpoint.

Bear in mind that you will be responsible for ensuring that the accompanying Xkit Token is valid, and if not (i.e. if you receive an HTTP 401 response) you'll need to refresh the user's token.

Group tokens not available

Note that if you are using the User Groups feature, you will not be able to retrieve access tokens from a Javascript client. Instead, you'll need to retrieve those tokens using the Get Group Connection API.

This is a security measure to prevent leaking of access tokens from one user to another.

Updated 12 days ago

Retrieving tokens from a Client


Retrieving 3rd Party Application Access Tokens from a Client

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.