How to Manage ProductMix’s Single Sign-On (SSO) Feature

Single Sign-On (SSO) is an identification method that allows users to access multiple applications and websites with just one set of login credentials.

ProductMix’s Single Sign-On (SSO) feature streamlines the process of user identification, allowing your customers to upvote, comment, or create a feature request without needing to go through additional email verification steps.
By integrating SSO, ProductMix communicates with your server to determine if a user is already registered, and if so, automatically identifies them.

The tutorial will show how to execute the SSO method with ProductMix.

Steps to implement the SSO method with ProductMix #

Provide a URL for ProductMix to redirect users to, where they can either log in or sign up. If the user is already logged in, simply redirect them back to the provided redirect URL as can be seen from point 2.

ProductMix will send a request to your provided URL, appending a `redirectUrl` parameter.

For example, if your URL is `https://example.com/sso`, ProductMix will call `https://example.com/sso?redirectUrl=https://app.ProductMix.ai/backend/api/v1/sso/fallback/productSlug/`.

To implement SSO, you’ll need to:

Create a JSON Web Token (JWT) containing the user’s `email` and `name`.
Sign the JWT with ProductMix’s provided `SSO Token` to ensure the request originates from your server.
Make an HTTP GET request to the `redirectUrl` with the created token attached.

An example of the request can be found below:

HTTP GET


https://app.ProductMix.ai/backend/api/v1/sso/fallback/productSlug/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

ProductMix will validate the request, and if everything checks out, the user will be granted access to upvote, comment, or create a feature request without any need to login to the ProductMix system again.

Below you can find a code example for Node.js:

import jwt from 'jsonwebtoken';

const ProductMixSSOToken = 'ProductMixSSOToken'; // From Products -> SSO -> SSO Token
const user = {
  email: '[email protected]',
  name: 'Joe Doe',
};

const generatedJwtToken = jwt.sign(user, ProductMixSSOToken, { algorithm: 'HS256' });

For other programming languages, you can use an equivalent JWT library to create and sign the token with ProductMix’s SSO Token.

Here are some examples of popular languages:

Python #
import jwt;


ProductMix_sso_token = 'ProductMixSSOToken'  # From Products -> SSO -> SSO Token
user = {
    'email': '[email protected]',
    'name': 'Joe Doe',
}

generated_jwt_token = jwt.encode(user, ProductMix_sso_token, algorithm='HS256')
Ruby #
require 'jwt'

ProductMix_sso_token = 'ProductMixSSOToken'  # From Products -> SSO -> SSO Token
user = {
    'email': '[email protected]',
    'name': 'Joe Doe',
}

generated_jwt_token = JWT.encode(user, ProductMix_sso_token, 'HS256')
PHP #
<?php

require 'vendor/autoload.php';

use \Firebase\JWT\JWT;

$ProductMix_sso_token = 'ProductMixSSOToken'; // From Products -> SSO -> SSO Token
$user = [
'email' => '[email protected]',
'name' => 'Joe Doe',
];
$generated_jwt_token = JWT::encode($user, $ProductMix_sso_token, 'HS256');

By following these examples, you can implement ProductMix’s SSO feature in your preferred programming language. Once the JWT token is generated, signed, and sent to the `redirectUrl` provided by ProductMix, your users will be able to seamlessly interact with your platform, making it easier for them to upvote, comment, and submit feature requests.

That’s it! Those were the steps on how to manage ProductMix’s SSO feature.

Did this answer your question?