fetchClientSecrets callback.
How it fits together
1
Your frontend asks your backend for credentials
The SDK calls your
fetchClientSecrets function, which hits a route on your own server.2
Your backend calls the TORTUS launch endpoint
Authenticated with your client ID and secret, your server requests a launch token.
3
Your backend returns the launch token
The SDK exchanges the token to load and authenticate the embedded app.
The launch endpoint
Authenticate with HTTP Basic Authentication using your TORTUS-provided credentials:
Base64-encode
clientId:clientSecret and send it in the Authorization header.
Request body
All fields are optional. Send what’s relevant to your integration.string
To help identify and resume the correct user, send their first and last name on every launch. After their first launch, also send the returned userId. Include any other fields relevant to your integration.
string
Your own internal user ID, kept as a reference label on the TORTUS user. This is not a resume
or lookup key: sending it does not match an existing user. Only
userId resumes a user.object
User information to associate with this session.
Response
If the user doesn’t already exist, TORTUS creates one and returns it in the response. A newly created user only becomes valid once the launch token has been exchanged.string
The token to pass to the SDK. Valid for 5 minutes.
string
The TORTUS user ID for this session. Save it to resume the session later via
userId.number
Seconds until the token expires.
Persisting and resuming users
Each launch either resumes an existing TORTUS user or creates a new one. Which one you get depends entirely on whether you senduserId.
The rule is simple:
- First launch for a person: call the endpoint without
userId(optionally withexternalUserIdanduserPayload). Then useuser_idfrom the response and save it against that person in your own system. - Every later launch for the same person: send that saved value as
userIdto resume them.
userId in step 2, and you create a duplicate user on every login.
Here is the same loop in your launch route:
Wiring it into the SDK
Return the token fromfetchClientSecrets. The SDK calls this whenever it needs fresh credentials.