Introduction
Platforms
Single Sign-On
These are instructions on how to generate Single Sign-On tokens on your server. These token can be used to authenticate your users in our web/mobile widget.
  1. Here's how it works:
    • We give you a private key. Store this on your server and don't share it.
    • When a user wants to use the widget, send a request to your server to generate an SSO token.
    • On your server, generate a token using the snippet below.
    • Pass the token back to your app and into our widget.
    • We'll use that token to authenticate your user.
  2. 1. Install a JWT library
    We use JSON Web Tokens to securely authenticate your users. First, install the appropriate JWT library for your server.
    Node.js
    Java
    PHP
    Python
    Ruby
    npm install --save jsonwebtoken
  3. 2. Generate tokens on your server
    Node.js
    Java
    PHP
    Python
    Ruby
    var jwt = require('jsonwebtoken');
    
    var PrivateKey = 'YOUR_PRIVATE_SSO_KEY';
    
    function createCannyToken(user) {
      var userData = {
        avatarURL: user.avatarURL, // optional but preferred
        email: user.email,
        id: user.id,
        name: user.name,
      };
      return jwt.sign(userData, PrivateKey, {algorithm: 'HS256'});
    }
  4. Questions
    If you have any questions or issues, email us at support@canny.io and we'll get back to you ASAP.