Viewer-based credentials on Posit Connect
Source:R/viewer-based-credentials.R
connect_viewer_token.RdRequest an OAuth access token for a third-party resource belonging to the user associated with a given Shiny session. This works by exchanging a short-lived session credential for OAuth tokens issued to the client managed by the Connect server, without the Shiny app in question having to manage the user's authentication flow (or the associated client credentials) itself.
Usage
connect_viewer_token(
resource = NULL,
scope = NULL,
session = get_connect_session(),
server_url = Sys.getenv("CONNECT_SERVER"),
api_key = Sys.getenv("CONNECT_API_KEY")
)
has_viewer_token(..., session = get_connect_session())Arguments
- resource
The URI that identifies the resource that the client is trying to access, if applicable.
- scope
Scopes to be requested from the resource owner.
- session
A Shiny session object. By default, this grabs the Shiny session of the parent environment (if any), provided we are also running on Connect.
- server_url
The Connect server to exchange credentials with. Defaults to the value of the
CONNECT_SERVERenvironment variable, which is set automatically when running on Connect.- api_key
An API key for the Connect server. Defaults to the value of the
CONNECT_API_KEYenvironment variable, which is set automatically when running on Connect.- ...
Further arguments passed on to
connect_viewer_token().
Value
connect_viewer_token() returns an httr2::oauth_token.
has_viewer_token() returns TRUE if the session has a viewer
token and FALSE otherwise.