View source: R/viewer-based-credentials.R
connect_viewer_token | R Documentation |
Request 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.
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())
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 |
api_key |
An API key for the Connect server. Defaults to the value of
the |
... |
Further arguments passed on to |
connect_viewer_token()
handles caching automatically.
connect_viewer_token()
returns an httr2::oauth_token.
has_viewer_token()
returns TRUE
if the session has a viewer
token and FALSE
otherwise.
token <- "default-token"
if (has_viewer_token()) {
token <- connect_viewer_token()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.