Exchange token flow
In this case, mini app is independent to host app, and is developed by a separated develop team.
#
General flow#
Implementation steps for host appTeko IAM Backend
#
1. Login to Please use TerraAuth to do this.
MiniApp
(that you want to exchangeIdToken for) with Teko IAM Backend
#
2. Register the - Request
MiniApp
dev team to provide you anaudience
string that identify theirMiniApp
- Contact Terra team with this
audience
, we will setup it for you
#
Implementation steps for mini appMiniAppClient
, implement code to get the idToken
from Hestia
and send to MiniAppBackend
#
1. In To get the IdToken
from Hestia
, according your MiniAppClient
platform please refer NativeMiniApp, WebMiniApp, ReactNativeApp
MiniAppBackend
, implement code to verify the idToken
#
2. In The idToken
includes following information:
Property | Description | Type | Constraint |
---|---|---|---|
iss | The Issuer of the token (will be Teko IAM backend, depend on environment) | string | required |
aud | The audience that this token is intended for | string | required |
sub | The identifier for the user | string | required |
iat | The time the token was issued | string | required |
exp | Expiration time on or after which the token must not be accepted. Represented in Unix time (integer seconds) | string | required |
name | User profile name | string | required |
email | User profile email | string | optional |
phone_number | User profile phone number | string | optional |
For example, an idToken
looks like this:
Some fields that mini apps need to care for:
iss
to ensure that thisidToken
is issued by Teko IAM backend, not another untrusted sourcesaud
to ensure that thisidToken
is for thisMiniApp
, not another mini app (you send this toHostApp
dev team asaudience
before)sub
is the user identifier
And lastly but the most important, mini app need to verify the idToken
with public key from Teko IAM backend. Keep in mind that the keys are changed periodically so best practice is to get it through API below, and cache for performance:
Environment | Url to get public keys |
---|---|
dev | https://oauth.develop.tekoapis.net/.well-known/jwks.json |
stage | https://oauth.stage.tekoapis.net/.well-known/jwks.json |
production | https://oauth.tekoapis.com/.well-known/jwks.json |
After idToken
is verified, MiniAppBackend
can issue a miniAppAccessToken
for MiniAppClient
.