Skip to main content

Overview

Authentication in GlobalTV Roku is credential-based. The user enters a username and password on the LoginScreen, and AuthTask calls the backend to validate them. On success, credentials are saved to the Roku Registry and used for auto-login on the next launch. A background session check re-authenticates at a fixed interval while the app is running.

AuthTask

Background task that performs the HTTP auth request and writes result fields

RegistryManager

Persists and retrieves credentials under the GlobalTV registry section

LoginScreen

Captures username and password using Roku’s on-device keyboard dialog

GTV_AuthClassifyFailure

Classifies every auth failure into one of five reason codes

Auth flow

1

User enters credentials

LoginScreen opens a StandardKeyboardDialog for the username field, then another for the password field. On submit, it calls TryLogin(), which first requests the Roku email via ChannelStore.getUserData (RFI), then starts AuthTask.
2

Server resolution

AuthTask calls GTV_ResolveServerForAuth(), which iterates the server probe list — LAN servers first, then the public WAN server — using health-check pings. The first server that responds becomes the active server for this session and is saved to the Registry (lastServer key).
3

Auth HTTP request

AuthTask issues a GET to the auth endpoint with URL-encoded credentials:
The endpoint pattern (from AppConstants.PATH_AUTH_TPL) is:
4

Response parsing

On HTTP 2xx, the task parses the JSON body and checks the subscriberStatus, subscriber_active, or active fields to confirm the subscriber is active. If any field signals an inactive account, the task classifies the failure and exits without saving credentials.
5

Success: credentials saved

On a fully successful auth, AuthTask saves credentials to the Registry and sets global state:
6

LoginScreen receives result

LoginScreen observes AuthTask.done. On success, it emits loginSucceeded = true with loginResult (username, password, rokuEmail). MainScene handles the rest of the launch sequence.

Auth endpoint

The endpoint template is defined in AppConstants as PATH_AUTH_TPL:
At runtime, AuthTask builds the URL by URL-encoding both values:

Auto-login

On every app launch, MainScene checks whether credentials exist in the Registry before showing the LoginScreen:
If credentials are found, MainScene skips the LoginScreen and starts AuthTask directly with the saved values.

Registry keys

All registry values are stored under the GlobalTV section (REG_SECTION = "GlobalTV").

Session re-auth check

After a successful launch, MainScene runs a periodic re-auth check to detect expired or revoked sessions while the app is in use.
If re-auth fails with a credential or inactive reason code, the user is sent back to the LoginScreen with a pre-populated error notice.

Timeouts and retries

The LoginScreen also arms a guard timer to cancel a hung auth attempt. The guard duration is computed as:

Failure classification

GTV_AuthClassifyFailure maps every auth error to one of five integer reason codes. Both AuthTask and PlaylistTask call this function to decide how to present errors to the user and whether to clear credentials.

Reason codes

Function signature

Parameters:
  • httpCode — The HTTP response code. -1 immediately returns AUTH_REASON_NETWORK_DOWN.
  • reasonText — A string hint from the response (e.g. the reason or message field). May be invalid.
  • bodyText — The raw response body string or parsed object. The function extracts signal text from nested JSON keys (message, reason, error, detail, status, user_inactive_reason, subscriberDisabledReason).
  • subscriberActive — Boolean hint from a parsed subscriber status field. If explicitly false, returns AUTH_REASON_INACTIVE.

Classification logic

Signal text is Unicode-normalized (accented characters stripped) and lowercased before pattern matching, so Spanish and English error messages from the backend are handled identically.

How LoginScreen reacts to each code