Authentication
Your app already knows who the user is. The mini-app turns that identity into a TrueVisions entitlement through the TrueID Account Wise (AAA) binding flow. From the host's side it is one POST: open the WebView on the landing endpoint with your access token and let the redirects run.
How it works
- Your app opens the WebView with
POST /[lang]/[partner]/auth/landingand your user's access token in the body. - The mini-app server asks AAA for an authorization code for that token (PKCE, signed state, ten-minute validity).
- If the user is already bound to TrueID, AAA returns a code, the server exchanges it and redirects to the partner home with a TrueVisions access token in the URL fragment. The viewer is signed in.
- If the user must bind first, the WebView is redirected to the AAA binding page (
sdk-identity.trueid.net). When it completes, AAA sends the WebView back to the mini-app's callback, which finishes the exchange and lands on the partner home. - Anything else redirects to a localised error page (
/auth/error?code=…).
Account Wise flow
The full picture behind the landing POST: which host sends what, the AAA binding and exchange round trips, and what reaches the browser.
- Landing. Each host POSTs to its own landing endpoint (
/[lang]/[partner]/auth/landing). A per-partner adapter reads the credential (table below). A viewer with no partner token enters at/auth/startinstead: they log in on the TrueID login page, which returns anauth_codeto the same callback (step 4). - Binding state.The server calls AAA's request-code API with the partner token, a PKCE challenge and a signed
state. A code back means the user is already known. - Not known. AAA answers 14300, 14272 or 14222; the WebView is sent to the AAA binding page (a redirect, or a self-submitting form when AAA wants a POST).
- Bound. The binding page redirects to
/auth/[partner]/callbackwithauth_codeand the samestate; on failure it redirects witherror_codeand the viewer lands on the error page. - Exchange.The server trades the code plus the PKCE verifier for an access token at AAA's exchange endpoint.
- Client side.Only the access token reaches the browser, in the URL fragment. The design's "maintain token's session" is the WebView's memory plus
sessionStorage; there is no server session.
| Host | Sends | Path |
|---|---|---|
| TrueApp | trueapp-authorization (or partner_token / bearer), trueapp-device-id, trueapp-session-id | Binding + exchange |
| TMN | tmn-access-token | Binding + exchange |
| 7Eleven | Token in the body (access_token, field name to be confirmed) | Binding + exchange |
| TrueID | Authorization: Bearer bridged TID token | Straight to the client, no AAA |
The landing request
Send a POST with application/x-www-form-urlencoded or application/json. The response is a redirect chain; the WebView follows it.
POST https://mini-app.truevisions.co.th/th/trueapp/auth/landing
Content-Type: application/x-www-form-urlencoded
partner_token=eyJhbGciOi…&device_id=8f1c…&session_id=4b2e…&platform=ANDROID&version=9.12.0&device_model=Pixel%208| Field | Required | Meaning |
|---|---|---|
partner_token | yes | Your app's access token for the user (the JWT AAA verifies). Also accepted: auth_token, access_token, an Authorization: Bearer header, x-partner-token. Any of these can also be a query param. |
device_id | recommended | Stable device identifier your app already reports to TrueID. |
session_id | recommended | Your app session id. A UUID is generated when omitted. |
platform | yes | iOS or ANDROID. Selects the AAA client id and partner code. |
version | recommended | Your app version, e.g. 9.12.0. |
device_model | optional | Device model string. Derived from the user agent when omitted. |
The lang segment (th / en) picks the language of every page that follows, including the error page. TrueID users (partner = trueid) pass a bridged token the same way and skip AAA entirely.
What the WebView will see
| Outcome | Response |
|---|---|
| Signed in | 303 to /[lang]/[partner]#at=…&exp=…, then the partner home renders signed in. |
| Binding required | 303 to the AAA binding page, or a self-submitting HTML form when AAA wants a POST. The binding page later redirects to /auth/[partner]/callback?code=…&state=…, which lands on the partner home like above. |
| Failure | 303 to /[lang]/[partner]/auth/error?code=…. |
Error codes: missing_credentials, unknown_partner, invalid_state, trueapp_token, request_code, exchange, and aaa_<code>for AAA's own numeric codes.
Knowing whether the viewer is signed in
After every page load inside a WebView the mini-app posts an auth-state message. Use it to decide whether to show your own subscribe entry points or to retry the landing POST when a token has expired.
{ "channel": "truevision-app", "type": "auth-state", "state": "signed-in" }
{ "channel": "truevision-app", "type": "auth-state", "state": "signed-out" }- The token lives in the WebView's
sessionStorage. Destroying the WebView signs the viewer out; re-open it with the landing POST. - Opening a browse URL directly with
loadUrlkeeps an existing session in the same WebView. - Every page needs a signed-in viewer. Signed out (or with an expired token) the page starts TrueID sign-in itself (
/auth/start); if the player's token is rejected mid-session it postssign-in. See Player.
Domains the WebView must reach
| Domain | Purpose |
|---|---|
mini-app.truevisions.co.th | The mini-app itself. |
sdk-identity.trueid.net | AAA binding page (pre-production: sdk-identity.trueid-preprod.net). |
identity.trueid.net | TrueID login page for viewers without a partner token (pre-production: identity.trueid-preprod.net). |
*.dmpcdn.com | Artwork and feeds. |
tvs-streamer.trueid.net | Stream lookup, called from the page (pre-production: tvs-streamer.trueid-preprod.net). |
| Stream and licence hosts | Returned by the stream lookup; provided at onboarding. |
Testing
Non-production deployments include a mock AAA and a mock host page for the partner-token path. The no-token path always uses the real TrueID login page, which only accepts the callback URL registered with AAA, so test it on a deployed environment, not on localhost. Open https://mini-app.truevisions.co.th/api/mock/host?lang=en&partner=trueapp in a browser, pick a scenario and submit: bound signs straight in, unbound runs the binding page round trip, expired shows the error page. Point your WebView at the same URL to exercise your bridge and redirect handling end to end.