Analytics Token Generation
Your mobile app will use Analytics JSON web token (JWT) to allow the app to communicate with Cirrent Cloud This token is generated by your cloud and is signed with your APP secret.
Token Format
The token format will be: apiKey::jwt-token where jwt-token is as defined below.
Header :
The header is a standard JWT header, using the HS256 algorithm.
{"typ":"JWT", "alg":"HS256"}
Payload:
The payload is the signed JWT token, which includes the following claims:
Claim |
Contents |
Comments |
iss |
Issuer of this token (Account ID) |
You can get Account ID from User Management Console page) |
iat |
Time token was issued (seconds in epoch) |
|
exp |
Expiration date for this token (seconds in epoch) |
|
owner |
The Owner ID for this app |
You can see the results of the binding in User Management Console page ) |
scope |
‘analytics’ |
|
devices |
Array of device IDs Example: ['device1','device2','device3'] |
Must be an array even if it's a single device
|
Token Validator
You can validate the token using the token validator here: https://console.cirent.com/dev-tools
Sample code for Generating Analytics Token
Here's a code snippet in Node.js. Implementation examples for other languages can be found at https://jwt.io.
var jwt = require('jsonwebtoken');
let accountId = 'account_number_from_console';
let ownerId = 'enter_app_owner_ID';
let scope = 'analytics';
let expiresIn = 60 * 60 * 24 * 30;
let apiKey = 'enter_app_api_key_here';
let apiKeySecret = 'enter_api_secret_here';
var token = jwt.sign({
iss: accountId,
owner: ownerId,
scope: scope,
demo_devices: 'false'
}, apiKeySecret, { expiresIn: expiresIn });
console.log('token=' + apiKey + '::' + token);
Comments
0 comments
Please sign in to leave a comment.