Exchange Own Token
If your app uses own Auth backend, you can exchange it's token for Terra access_token
following this guide.
#
General flowThis flow requires several integration steps between your Auth backend and our system, please follow next section for details
#
Implementation steps#
Implement your Auth backend to generate the idTokenCurrently, we only support JWT-decodable token with following claims
#
HeaderProperty | Description | Type | Constraint |
---|---|---|---|
typ | Only accept “JWT” | string | |
alg | Only accept “RS256” | string | |
kid | The kid for the public key used to sign this token | string | required |
Example:
#
PayloadProperty | Description | Type | Constraint |
---|---|---|---|
iss | The Issuer Identifier for the Issuer of the response | string | required |
aud | The audience that this token is intended for. If provider follows Auth2.0 and needs to verify claim aud, they need to register allowed list aud to IAM Service | 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 | optional | recommended |
phone_number | User profile phone number | optional | recommended |
Example:
Given this context:
Company
sample_company
has an Auth backend (https://oauth.sample_company.com)Company has 2 apps
app_1
andapp_2
that use this Auth backendThe
idToken
generated forapp_1
will look like:
#
Implement your Auth backend to return public keyThis is the public key associated with the private key that you used to sign the above idToken
, as an example the Google's api is https://www.googleapis.com/oauth2/v3/certs.
The api url is jwks_uri
in next step.
#
Send us registration information so we can integrate your Auth backendProperty | Description | Type | Constraint |
---|---|---|---|
name | Your Auth backend name | string | required |
provider | Your Auth backend identifier (will be used in your client code for logging in later) | string | required |
issuer | Authenticator issuer which is used when IAM verifies id_token for this issuer | string | required |
jwks_uri | The API provider exposed jwks which contains public_key to verify JWT id_token (https://tools.ietf.org/html/rfc7517) | string | required |
client_id | Allowed 3rd-party client | string | required |
Example (using same above context)
#
Enable custom login method in Terra ConsolePlease contact us we will setup it for you
#
Implement your client app to log in#
Installation- Android
- iOS
- Flutter
#
UsageAfter user logged into your app and received the idToken
from your Auth backend, use this code to log in
- Android
- iOS
- Flutter
Where
idToken
is the token that you received from your Auth backend after logging in successfullyprovider
is the value that you sent us at the step before.
with
Where: idToken
is the token that you received from your Auth backend after logging in successfully
Note To login with custom token credential, except idToken
, you should config provider
on Terra Console. Contact Terra team to get more information.