Contents        

The auto-login feature requires several changes on the frontend and backend of the service that is going to be integrated.

Prerequisites

A pre-shared secret key is used to verify that the login request is valid and coming from your (client’s) backend. Each service desk project has its own secret key. To obtain the key, please go to a particular project’s settings, enable the auto-login feature and generate a new secret key:

The pre-shared secret key should be stored in the backend.

Logging in

While performing user login on the website, the service should generate and issue a JWT access token for a chat and sign it with the pre-shared secret, as shown in the example below:


Example
const header = { 
  alg: 'HS256',
  typ: 'JWT'
};
const payload = { 
  email: "user@example.com",
  displayName: "User Account Name",
  iat: Date.now() / 1000, //unix timestamp in seconds
  exp: Date.now() / 1000 + 60 * 5 //token expiry date
};
const token = KJUR.jws.JWS.sign( //example using jsrsasign library
  "HS256",
  JSON.stringify(header),
  JSON.stringify(payload),
  sharedSecret
);


The service’s frontend should receive this token and call chat’s SSO login API:

Example
try {
  await spartezSupportChat.sso.login(token);
} catch (exception){
  //handle exception
}

During the login operation, an error may occur. In that case, an exception will be thrown. To get the error description, you can access exception.message property.

After that, the user will be logged in with credentials described in the token, and all tickets will have the reporter field assigned to the SSO user, keeping the original user in the request participants.

Limitation 1: If the login failed in the case that the customer has an account already in atlassian.com, please check if they have set the visibility of their contact email to "Anyone" so that the Chat app can see the email address and match the two.

(Here's the link of profile setting: Profile and Visibility)

Limitation 2: Due to Jira user creation process, while logging in with non-existing JSM user email, it may take some time for user to be fully created on Atlassian side (less that 1 minute). During this process, trying to re-login with newly created user may lead to an error, which is temporary.


Logging out

To log out, the service’s frontend should call await spartezSupportChat.sso.logout();.


  • No labels

This page has no comments.