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
redirect_uri (see below) which
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.
1 2 3
client id obtained from Google Developers Console
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 '/'
either "online" (no refresh token) or "offline" (refresh token), determines whether a refresh token is returned in the response
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.
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
this information by providing as function arguments or by defining these
options. For example, you can put lines like this into a Project-specific
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.