Skip to main content

Authentication

Most of the endpoints require an Authorization header with a JWT token in it. To obtain a token you can either make a call to authenticate API as self sign a token with provided private key.

Create Token

post /authentication

This endpoint allows you to create a JWT token

Headers

NameTypeValue Description
Content-Type *stringapplication-json

Body

NameTypeValue Description
strategy *stringapp-secret
appId *stringApp ID provided by us
appSecret *stringApp Secret provided by us

Auth Revalidation

post /authentication

With this endpoint, you can validate the issued token.

Headers

NameTypeValue Description
Content-Type *stringapplication-json
Authorization *stringBearer <jwt>

Body

NameTypeValue Description
strategy *stringapp-token

Self Signed Tokens

When you get app credentials from us, along with appId, appSecret we will also provide you with a ECDSA P-256 Primary key. Using this you can sign token yourself using ES256 algorithm. Following is a smple nodejs code for self signed tokens -

import jwt from 'jsonwebtoken';

function getRefrensToken(appId, privateKey) {
return jwt.sign(
{
iss: appId, // appId provided by us
aud: 'serana',
sub: appId, // appId provided by us
auth: {
entity: 'app',
strategy: 'app-iss-app-token',
},
},
privateKey,
{
algorithm: 'ES256', // required
expiresIn: '1h', // keep as short as possible and not more then 1 day
},
);
}

// appId and private key will be provided by us
const privateKey = `
-----BEGIN PRIVATE KEY-----
SAMPLEKEYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyYOUSHALLNOTPASS/
-----END PRIVATE KEY-----
`;
const appId = 'fooApp';

console.log(getRefrensToken(appId, privateKey));

Validate Self Signed Token

post /authentication

With this endpoint, you can validate the issued token.

Headers

NameTypeValue Description
Content-Type *stringapplication-json
Authorization *stringBearer <jwt>

Body

NameTypeValue Description
strategy *stringapp-iss-app-token