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    

Provision Users via API

Use the Xkit API to create tokens for your users

The simplest way to create Xkit tokens for your users is to provision them using the Xkit Platform API.

Use the Provision Platform User endpoint with an active API Key.

The only data you need to provide is an external_id - an identifier that uniquely identifies the user in your systems.

A simple example with an ExpressJS server follows.

Provision a user

On your server, when a user has authenticated, call this endpoint with your system's user ID as the external_id parameter.

// `app` is a configured Express App with authentication middleware
// that provides the `req.user` parameter for authenticated users.
import axios from 'axios'

app.use(async (req, res) => {
  if (!req.user) return
  const { access_token } = await axios({
    baseUrl: 'https://app.xkit.co/api/platform',
    method: 'post',
    url: '/users',
    auth: {
      username: "your_publishable_key",
      password: "your_secret_key"
    },
    data: {
      user: { external_id: req.user.id }
    }
  })
 
  res.locals.xkitToken = access_token
})

Provide the token to the front-end

Retrieve the returned access_token and provide it to your front-end (e.g. by rendering it in HTML or by providing it via an API call)

app.get('/home', (req, res) => {
    res.render('home')
})

Log the user into Xkit

Use the access_token with the xkit.js library on the front-end to authenticate the user.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My App</title>
  </head>
  <body>
        <script src="https://myapp.xkit.co/xkit.js"></script>
    <script>xkit.ready(() => xkit.login("{{ xkitToken }}"))</script>
  </body>
</html>

See the Hosted Integration Catalog for more examples of what to do with the Xkit User Token.

Updated 2 months ago


What's Next

Overview

Provision Users via API


Use the Xkit API to create tokens for your users

Suggested Edits are limited on API Reference Pages

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