| OAuthProvider | R Documentation |
S7 class describing an OAuth 2.0 or OpenID Connect provider. It stores the provider's endpoints and the rules shinyOAuth should follow during login, callback handling, token exchange, and optional OIDC checks.
This is a low-level constructor intended for advanced use. Most users should
prefer the helper constructors oauth_provider() for generic OAuth 2.0
providers or oauth_provider_oidc() / oauth_provider_oidc_discover() for
OpenID Connect providers. Those helpers enable secure defaults based on the
presence of an issuer and available endpoints.
OAuthProvider(
name = character(0),
auth_url = character(0),
token_url = character(0),
userinfo_url = NA_character_,
introspection_url = NA_character_,
revocation_url = NA_character_,
par_url = NA_character_,
require_pushed_authorization_requests = FALSE,
authorization_request_front_channel_mode = "compat",
request_object_signing_alg_values_supported = character(0),
request_object_encryption_alg_values_supported = character(0),
request_object_encryption_enc_values_supported = character(0),
request_object_encryption_jwk = NULL,
require_signed_request_object = FALSE,
request_parameter_supported = NA,
request_uri_parameter_supported = NA,
require_request_uri_registration = NA,
token_endpoint_auth_signing_alg_values_supported = character(0),
dpop_signing_alg_values_supported = character(0),
authorization_response_iss_parameter_supported = FALSE,
response_modes_supported = character(0),
issuer = NA_character_,
issuer_match = "url",
use_nonce = FALSE,
use_pkce = TRUE,
pkce_method = "S256",
userinfo_required = FALSE,
userinfo_id_selector = function(userinfo) userinfo$sub,
userinfo_id_token_match = FALSE,
userinfo_signed_jwt_required = FALSE,
id_token_required = FALSE,
id_token_validation = FALSE,
id_token_at_hash_required = FALSE,
extra_auth_params = list(),
extra_token_params = list(),
extra_token_headers = character(0),
mtls_endpoint_aliases = list(),
tls_client_certificate_bound_access_tokens = FALSE,
token_auth_style = "header",
jwks_cache = cachem::cache_mem(max_age = 3600),
jwks_pins = character(0),
jwks_pin_mode = "any",
jwks_host_issuer_match = FALSE,
jwks_host_allow_only = NA_character_,
allowed_algs = c("RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "EdDSA"),
allowed_token_types = "Bearer",
leeway = getOption("shinyOAuth.leeway", 30)
)
name |
Provider name (e.g., "github", "google"). Cosmetic only; used in logging and audit events |
auth_url |
Authorization endpoint URL |
token_url |
Token endpoint URL |
userinfo_url |
User info endpoint URL (optional) |
introspection_url |
Token introspection endpoint URL (optional; RFC 7662) |
revocation_url |
Token revocation endpoint URL (optional; RFC 7009) |
par_url |
Optional Pushed Authorization Request (PAR) URL (RFC 9126).
When set, shinyOAuth first sends the authorization request from server to
provider and then redirects the browser with the returned |
require_pushed_authorization_requests |
Logical. Whether the provider
requires authorization requests to be sent via PAR. When |
authorization_request_front_channel_mode |
Character scalar controlling
which browser-visible outer parameters shinyOAuth keeps when the actual
authorization request is carried by JAR or PAR. Use |
request_object_signing_alg_values_supported |
Optional vector of JWS
algorithms that the provider advertises for signed Request Objects (RFC
9101). This is mainly used for early validation when an OAuthClient
sends |
request_object_encryption_alg_values_supported |
Optional vector of JWE key-management algorithms that the provider advertises for encrypted Request Objects. This metadata is used for early validation when an OAuthClient enables Request Object encryption. |
request_object_encryption_enc_values_supported |
Optional vector of JWE content-encryption algorithms that the provider advertises for encrypted Request Objects. This metadata is used for early validation when an OAuthClient enables Request Object encryption. |
request_object_encryption_jwk |
Optional explicit recipient public key used to encrypt Request Objects when discovery-backed JWKS selection is not available or when you need to pin one specific encryption key. Accepts an OpenSSL public key, a PEM public-key string, a parsed JWK object, or a JWK JSON string. |
require_signed_request_object |
Logical. Whether the provider requires
signed Request Objects for authorization requests. When |
request_parameter_supported |
Logical or |
request_uri_parameter_supported |
Logical or |
require_request_uri_registration |
Logical or |
token_endpoint_auth_signing_alg_values_supported |
Optional vector of
JWS algorithms that the provider advertises for JWT-based client
authentication ( |
dpop_signing_alg_values_supported |
Optional vector of JWS algorithms
that the provider advertises for DPoP proof JWTs (RFC 9449). This
metadata is used for early validation of |
authorization_response_iss_parameter_supported |
Logical. Whether the
provider advertises RFC 9207 support for returning an |
response_modes_supported |
Optional character vector of OAuth/OIDC
|
issuer |
Optional OIDC issuer URL. You need this when you want ID token
validation. shinyOAuth uses it to verify the ID token |
issuer_match |
Character scalar controlling how strictly the discovery
document's
In most cases, keep the default |
use_nonce |
Whether to use OIDC nonce. This adds a |
use_pkce |
Whether to use PKCE. This adds a |
pkce_method |
PKCE code challenge method ("S256" or "plain"). "S256" is recommended. Use "plain" only if you are working with a provider that does not support "S256". |
userinfo_required |
Whether to fetch userinfo after token exchange.
User information will be stored in the For the low-level constructor |
userinfo_id_selector |
A function that extracts the user ID from the userinfo response. Should take a single argument (the userinfo list) and return the user ID as a string. This is used for helpers that need a provider-specific user identifier, such
as audit fields and UserInfo-to-ID-token subject matching. If you configure a
selector other than |
userinfo_id_token_match |
Whether to fail closed if UserInfo cannot be
bound to a validated ID token subject. Whenever both UserInfo and a
validated ID token are available, shinyOAuth compares the validated ID token
For |
userinfo_signed_jwt_required |
Whether to require that the userinfo
endpoint returns a signed JWT (
This prevents unsigned or weakly signed userinfo payloads from being treated
as trusted identity data. Requires Note: |
id_token_required |
Whether to require an ID token to be returned
during token exchange. If no ID token is returned, the token exchange
will fail. This only makes sense for OpenID Connect providers and may
require the client's scope to include Note: At the S7 class level, this defaults to FALSE so that pure OAuth 2.0
providers can be configured without OIDC. Helper constructors like
|
id_token_validation |
Whether to perform ID token validation after token exchange.
This requires the provider to be a valid OpenID Connect provider with a configured
Note: At the S7 class level, this defaults to FALSE. Helper constructors like
|
id_token_at_hash_required |
Whether to require the |
extra_auth_params |
Extra parameters for authorization URL |
extra_token_params |
Extra parameters for token exchange |
extra_token_headers |
Extra headers for back-channel token-style requests (named character vector). shinyOAuth applies these headers to token exchange, refresh, introspection, revocation, and PAR requests. Use this only for headers you intentionally want on that full set of authorization-server calls. |
mtls_endpoint_aliases |
Optional named list of RFC 8705 mTLS endpoint
aliases. Names should follow the metadata keys such as |
tls_client_certificate_bound_access_tokens |
Logical. Whether the
authorization server advertises RFC 8705 capability to issue
certificate-bound access tokens. This describes server capability; the
client still has to opt into mTLS separately. When |
token_auth_style |
How the client authenticates at the token endpoint. One of:
|
jwks_cache |
Cache used for the provider's signing keys (JWKS). If not
provided, shinyOAuth creates an in-memory cache for 1 hour with
In most cases, a TTL between 15 minutes and 2 hours is reasonable. Shorter
TTLs pick up new keys faster but do more network work; longer TTLs reduce
traffic but may take longer to notice key rotation. If a new |
jwks_pins |
Optional character vector of RFC 7638 JWK thumbprints
(base64url) to pin against. If non-empty, fetched JWKS must contain keys
whose thumbprints match these values depending on |
jwks_pin_mode |
Pinning policy when |
jwks_host_issuer_match |
When TRUE, enforce that the discovery |
jwks_host_allow_only |
Optional explicit hostname that the jwks_uri must match.
When provided, jwks_uri host must equal this value (exact match). You can
pass either just the host (e.g., "www.googleapis.com") or a full URL; only
the host component will be used. If you need to include a port or an IPv6
literal, pass a full URL (e.g., |
allowed_algs |
Optional vector of allowed JWT algorithms for ID tokens.
Use to restrict acceptable |
allowed_token_types |
Character vector of acceptable OAuth token types
returned by the token endpoint (case-insensitive). Successful token
responses must always include |
leeway |
Clock skew leeway (seconds) applied to ID token |
# Configure generic OAuth 2.0 provider (no OIDC)
generic_provider <- oauth_provider(
name = "example",
auth_url = "https://example.com/oauth/authorize",
token_url = "https://example.com/oauth/token",
# Optional URL for fetching user info:
userinfo_url = "https://example.com/oauth/userinfo"
)
# Configure generic OIDC provider manually
# (This defaults to using nonce & ID token validation)
generic_oidc_provider <- oauth_provider_oidc(
name = "My OIDC",
base_url = "https://my-issuer.example.com"
)
# Configure a OIDC provider via OIDC discovery
# (requires network access)
if (interactive()) {
# Using Auth0 sample issuer as an example
oidc_discovery_provider <- oauth_provider_oidc_discover(
issuer = "https://samples.auth0.com"
)
}
# GitHub preconfigured provider
github_provider <- oauth_provider_github()
# Google preconfigured provider
google_provider <- oauth_provider_google()
# Microsoft preconfigured provider
# See `?oauth_provider_microsoft` for example using a custom tenant ID
# Spotify preconfigured provider
spotify_provider <- oauth_provider_spotify()
# Slack via OIDC discovery
# (requires network access)
if (interactive()) {
slack_provider <- oauth_provider_slack()
}
# Keycloak
# (requires configured Keycloak realm; example below is therefore not run)
if (interactive()) {
oauth_provider_keycloak(base_url = "http://localhost:8080", realm = "myrealm")
}
# Auth0
# (requires configured Auth0 domain; example below is therefore not run)
if (interactive()) {
oauth_provider_auth0(domain = "your-tenant.auth0.com")
}
# Okta
# (requires configured Okta domain; example below is therefore not run)
if (interactive()) {
oauth_provider_okta(domain = "dev-123456.okta.com")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.