How can we help you?

Understanding SSO Redirects

Swathy R
December 06, 2022

Hellonext uses its own authentication mechanism to either log users in or create a user account. If you want to override this to use your own authentication system, you've come to the right place!

Prerequisite


Your server should be set up to authenticate users and generate SSO Tokens.

Instructions

Your users will now no longer have to create a Hellonext account for them to be able to access your feedback page. Instead, we will redirect them to your application, where you will authenticate the user, create a SSO token and redirect them back to Hellonext.

  1. Setup an authentication page on your website – We will send all users who land on your Hellonext page here to be authenticated. The user will then need to login to your website using your credentials.

  2. Send a request to your server to generate a single sign-on token – Once the user is logged in, generate an SSO token. Read more here→

  3. Redirect them back to Hellonext – When we redirect users to your application, we'll include a redirect query parameter. You will need to send users back to us with both the redirect URL and SSO token in the query parameters, once they've been logged in.

Add the URL of your newly created page to the admin dashboard and follow the steps on-screen.

Snippet


Use the following snippet to redirect users back to Hellonext. You will need to fill in the part that generates an SSO token.

function getQueryParameterByKey(key) { 
  var pairStrings = window.location.search.slice(1).split('&'); 
  var pairs = pairStrings.map(function(pair) { 
    return pair.split('='); 
}); 
 return pairs.reduce(function(value, pair) { 
    if (value) return value; 
    return pair[0] === key ? decodeURIComponent(pair[1]) : null; 
 }, null); 
} 

function getSSORedirectURL(ssoToken) { 
  var redirectURL = getQueryParameterByKey('redirect'); 
  var domain = getQueryParameterByKey('domain'); 
  if (redirectURL.indexOf('https://') !== 0 || !domain) { 
    return null; 
  } 

  return 'https://app.hellonext.co/redirects/sso?domain=' + domain + '&ssoToken=' + ssoToken + '&redirect=' + redirectURL; 
} 

var redirectURL = getSSORedirectURL(ssoToken); 
if (redirectURL) { 
   window.location.assign(redirectURL); 
}

Also, here's the link to our repository for more information on SSO redirects. We've added code samples in the repository for your reference.

If you have any further assistance, feel free to contact us. ✨😃