Appearance
Users authentication
JWT Token
Authenticating your users on widget works through JWT token.
Tokens that you generate should be signed using key that you can generate in Backoffice settings (see details here). JWT token should have following payload:
sub
Unique identifer of user in your system. String between 1 to 128 characters.
iat
Date of token generation in unix timestamp format (seconds passed since 1 january 1970). Passing date of when token is already expired or future date will result in error. Each token expires 20 minutes after iat time.
displayName
Display name of user. String between 1 to 24 characters. Any character over 24 will be truncated.
avatar
Optional. Url to avatar, should start with protocol (either http:// or https://). If passed it must be either null or string up to 512 characters. Going over 512 characters or passing invalid string format will be treated as null.
TIP
To display avatar in best possible quality it should be a 24x24 square.
And here is TypeScript type for your convenience:
ts
type Payload = {
sub: string;
iat: number;
displayName: string;
avatar?: string | null;
}
Finally to authenticate your user on PointsInPlay widget, you can query your backend through tokenCallback and pass authentication state with generated token (if feasible).
If valid token is provided user will be either logged in or he will be given option to register after he toggles the widget. When widget encounters token with invalid payload user won't be able to authenticate and appriopriate error will be displayed.
TIP
Each time user is authenticated on widget his data is synchronized with data from token (displayName, avatar)