An OAuthToken holds credentials and user information returned after login.
The Shiny module supplies it as auth[["token"]], and handle_callback() returns
it for custom integrations. Pass it to perform_resource_req() to call an
API, or to the token helpers for refresh, introspection, and revocation.
Properties use @, for example auth[["token"]]@userinfo. Profile fields
depend on the provider.
Usage
OAuthToken(
access_token = character(0),
token_type = NA_character_,
refresh_token = NA_character_,
id_token = NA_character_,
expires_at = Inf,
userinfo = list(),
cnf = list(),
granted_scopes = character(0),
granted_scopes_verified = FALSE,
id_token_validated = FALSE,
original_id_token = NA_character_,
extra_fields = list(),
initial_extra_fields = list(),
smart_context = list(),
original_granted_scopes = character(0)
)Arguments
- access_token
Access token
- token_type
OAuth access token type (for example
BearerorDPoP)- refresh_token
Refresh token (if provided by the provider)
- id_token
ID token (if provided by the provider; OpenID Connect)
- expires_at
Numeric timestamp (seconds since epoch) when the access token expires,
NA_real_when the expiry is unknown, orInffor a non-expiring token- userinfo
List containing user information fetched from the provider's userinfo endpoint (if fetched)
- cnf
Optional binding metadata for an access token tied to a key or certificate. It can come from a token response, the access token's JWT payload, or an introspection response. For RFC 8705 certificate-bound tokens, this may contain
x5t#S256with the SHA-256 thumbprint of the client certificate that must accompany later requests. For DPoP-bound tokens, this may containjktwith the RFC 7638 thumbprint of the public JWK bound to the token. Whencnfis learned by locally parsing a raw JWT access token, shinyOAuth is observing the token payload and is not independently verifying the access-token signature. A token or introspection response received directly from the provider gives stronger confirmation.- granted_scopes
Normalized scope tokens currently associated with the access token. When a provider omits
scopein a token response, shinyOAuth carries forward the best-known scope set instead of dropping it.- granted_scopes_verified
Logical flag indicating whether the current token response explicitly proved
granted_scopes.FALSEmeans the scope set was assumed or carried forward because the provider omittedscope. Withintrospection_checks = "scope", provider introspection can verify the granted scope set.- id_token_validated
Logical flag indicating whether the ID token was cryptographically validated (signature verified and standard claims checked) during the OAuth flow. Defaults to
FALSE.- original_id_token
Initial login ID token retained as the refresh continuity baseline. Refresh never replaces it with a newer ID token. For manually constructed tokens, the first refresh initializes this from
id_tokenif omitted.- extra_fields
List of additional parameters from the latest successful token endpoint response. Excludes
access_token,token_type,refresh_token,id_token,expires_in,scope, andcnf, which have dedicated token properties. Defaults to an empty list. Successful refresh replaces this list, including when the response contains no extra fields.- initial_extra_fields
List of additional parameters from the initial successful authorization-code exchange. Preserved across refreshes and replaced on a new login. Defaults to an empty list for manually constructed tokens; refresh does not infer an initial response from
extra_fields.- smart_context
Internal interpreted SMART context. Empty for ordinary tokens; populated only by SMART token processing. Use
smart_context()on a connection to read it. Includes sensitive patient and identity references.- original_granted_scopes
Initial accepted SMART grant, preserved across refreshes to distinguish unchanged grants from strict scope reductions. Empty for ordinary OAuth tokens. Set by SMART token processing.
Details
Read token@id_token_claims for the decoded ID-token payload as a named list,
including standard and optional OIDC claims such as sub, iss, aud, acr,
amr, auth_time, nonce and at_hash. This property is read-only and returns
an empty list when the token is absent or cannot be decoded.
Decoding does not verify the signature. Check id_token_validated before
using these claims as a validated identity.
For validated Apple ID tokens, exact "true"/"false" strings in
email_verified are returned as logical values, as during validation.
The original signed id_token is retained unchanged.
Additional response parameters retain their parsed names and values,
including nested lists and explicit JSON null values (R NULL). Use
"custom_field" %in% names(token@extra_fields) to distinguish an absent field
from a field explicitly returned as null. These parameters are not ID
token claims and are not covered by id_token_validated. The initial
snapshot records the initial response data, not current access permissions.
No automatic merging, resource fetching, or interpretation is performed.
print() and format() redact both lists.
Examples
# Inside reactive server code, after a successful login:
# auth[["token"]]@userinfo
# auth[["token"]]@expires_at
# auth[["token"]]@id_token_validated
# auth[["token"]]@id_token_claims[["sub"]]
# auth[["token"]]@extra_fields[["custom_field"]]
# auth[["token"]]@initial_extra_fields[["custom_field"]]