MyNixOS website logo
Description

Manage 'OAuth' Credentials from 'Posit Connect'.

A toolkit for making use of credentials mediated by 'Posit Connect'. It handles the details of communicating with the Connect API correctly, 'OAuth' token caching, and refresh behaviour.

connectcreds

lifecycle R-CMD-check

connectcreds provides low-level utilities for Shiny developers and R package authors building tools that make use of Posit Connect’s viewer-based credentials.

Installation

You can install connectcreds from CRAN with:

install.packages("connectcreds")

Or, install the development version of connectcreds from GitHub with:

# install.packages("pak")
pak::pak("posit-dev/connectcreds")

Usage

connectcreds includes helper functions for implementing Posit Connect’s viewer-based credentials in Shiny applications. These helpers are meant to be called in the context of a Shiny server function, as follows:

server <- function(input, output, session) {
  token <- "PAT for local development"
  if (connectcreds::has_viewer_token()) {
    token <- connectcreds::connect_viewer_token()
  }

  # ...
}

Usually, though, these helpers will be used internally by packages that authenticate with various services. For example, here is a simplified version of gh::gh_token() that returns a GitHub OAuth token for the viewer on Connect but uses a GitHub personal access token when testing locally:

gh_token <- function() {
  rlang::check_installed("connectcreds", "for viewer-based authentication")
  if (connectcreds::has_viewer_token("https://github.com")) {
    token <- connectcreds::connect_viewer_token("https://github.com")
    return(token$access_token)
  }
  Sys.getenv("GITHUB_PAT")
}

server <- function(input, output, session) {
  # A Shiny output that shows the user's GitHub username:
  output$gh_handle <- renderText({
    resp <- gh::gh_whoami(.token = gh_token())
    resp$login
  })

  # ...
}

License

MIT (c) Posit Software, PBC.

Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows