Token
Last updated
Was this helpful?
Last updated
Was this helpful?
This option allows to generate automatic login tokens to login the viewers. A great way to use this feature is to autogenrate the login tokens via an API and create limited time login links.
To generate a token, create a new viewer group and select the token
login method. When you select this, you will be shown a signing key
, copy this signing key. This will be used to generate the login tokens.
To generate a login token, we create a Jwt token. This login token will be appended to the experience link.
The final url will look like this:
<deployment-link>?token=<generate-jwt-token>
An example url:
https://view.gmetri.com/v4/game/safehands_v2?token=34fhdf7asbfdsa09in2m1od.09u0dfa8nfdjajkbfe8uih32rjn.908ufdbsahbjfd9sabjhfdu
JSON Web Token (Jwt) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. A typical Jwt consists of three parts separated by dots (.
), which are header, payload and signature. Therefore, a JWT typically looks like the following. xxxxx.yyyyy.zzzzz
. More information about Jwts can be found .
This information is required to correctly identify a viewer on GMetri experiences. The payload for the JWT is shown below (the optional fields can be set as per requirement):
identifier
is the unique key by which you identify your viewers.
We recommend using npm package jsonwebtoken
to generate jwt tokens on the web (both on server and browser)
An example of generating a Jwt token in node.js
:
In your android experience, add the required dependencies for Chrome Custom Tabs and Jwt. Following is an example of gradle build dependencies:
Information on how to install dependencies for other build systems are in the links below:
The className ChromeCustomTabsJwt.java
implements two public methods:
initialize(String viewerIdentifier, String apiKey, String url, Context context)
launch()
Arguments:
viewerIdentifier - This is a JSON string containing information for the viewer
apiKey - A unique key generated for GMetri experiences.
url - Url of the experience
context - Context of your activity (this
)
An example implementation of the above classes:
To run GMetri experiences inside android apps, we recommend an implementation of Chrome Custom Tabs API. Detailed information on how to setup an android experience with Chrome Custom Tabs can be found in this
From this , copy two files: ChromeCustomTabsJwt.java
and ServiceConnectionCallback.java
into your android experience. These files together provide the interface for chrome custom tabs to run GMetri experiences.
To add more fields to viewerIdentifier JSON object refer to the section.