gs_webapp_auth_url

0th

Percentile

Build URL for authentication

Build the Google URL that googlesheets needs to direct users to in order to authenticate in a Web Server Application. This function is designed for use in Shiny apps. In contrast, the default authorization sequence in googlesheets is appropriate for a user working directly with R on a local computer, where the default handshakes between the local computer and Google work just fine. The first step in the Shiny-based workflow is to form the Google URL where the user can authenticate him or herself with Google. After success, the response, in the form of an authorization code, is sent to the redirect_uri (see below) which gs_webapp_get_token uses to exchange for an access token. This token is then stored in the usual manner for this package and used for subsequent API requests.

Usage
gs_webapp_auth_url(client_id = getOption("googlesheets.webapp.client_id"),
  redirect_uri = getOption("googlesheets.webapp.redirect_uri"),
  access_type = "online", approval_prompt = "auto")
Arguments
client_id

client id obtained from Google Developers Console

redirect_uri

where the response is sent, should be one of the redirect_uri values listed for the project in Google's Developer Console, must match exactly as listed including any trailing '/'

access_type

either "online" (no refresh token) or "offline" (refresh token), determines whether a refresh token is returned in the response

approval_prompt

either "force" or "auto", determines whether the user is reprompted for consent, If set to "auto", then the user only has to see the consent page once for the first time through the authorization sequence. If set to "force" then user will have to grant consent everytime even if they have previously done so.

Details

That was the good news. The bad news is you'll need to use the Google Developers Console to obtain your own client ID and secret and declare the redirect_uri specific to your project. Inform googlesheets of this information by providing as function arguments or by defining these options. For example, you can put lines like this into a Project-specific .Rprofile file:

options("googlesheets.webapp.client_id" = MY_CLIENT_ID) options("googlesheets.webapp.client_secret" = MY_CLIENT_SECRET) options("googlesheets.webapp.redirect_uri" = MY_REDIRECT_URI)

Based on Google Developers' guide to Using OAuth2.0 for Web Server Applications.

See Also

gs_webapp_get_token

Aliases
  • gs_webapp_auth_url
Documentation reproduced from package googlesheets, version 0.3.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.