terra

Generate Widget Session

Changed on

Generate a Terra widget session for user authentication.

Google Health uses the authenticated athlete's id as its reference and restricts the widget to GOOGLE_HEALTH. If this Firebase session has no athlete yet, the shared provisioner creates one. A supplied reference must belong to that session. Other providers keep the per-session flow below.

Legacy sessions pass a fresh, never-reused reference_id (not the Firebase UID) so Terra never sees the same reference twice across reinstalls — that's what stops the duplicate-account / orphaned-data bleeding (#979, #1094): no ambiguous state, user_reauth never fires. The Firebase UID and the device timezone (from the X-Device-Timezone header, PR #529) are persisted on a TerraSession row keyed by the widget session id Terra returns. The auth webhook reads the row by widget_session_id to recover the identity and rewrite the reference to the imperfect-api user id.

post/session

Request

  • Base URL
    https://api.imperfect.co (the document declares no server; this is the origin it was published from)
  • URL
    https://api.imperfect.co/session
  • Auth
    HTTP bearer

Headers

x-device-timezonestring nullable

Request body

provider'GOOGLE_HEALTH' nullable
reference_idstring nullable
languagestring
auth_success_redirect_urlstring required
auth_failure_redirect_urlstring required

Response

Successful Response

object required

Changes