googleAuth: Server side google auth (Shiny Module)

Description Usage Arguments Details Value See Also Examples

View source: R/googleAuthR_shiny.R

Description

Server part of shiny module, use with googleAuthUI

Usage

1
2
3
4
googleAuth(input, output, session, login_text = "Login via Google",
  logout_text = "Logout", login_class = "btn btn-primary",
  logout_class = "btn btn-default", access_type = c("online", "offline"),
  approval_prompt = c("auto", "force"), revoke = FALSE)

Arguments

input

shiny input

output

shiny output

session

shiny session

login_text

What the login text will read on the button

logout_text

What the logout text will read on the button

login_class

The CSS class for the login link

logout_class

The CSS class for the logout link

access_type

Online or offline access for the authentication URL

approval_prompt

Whether to show the consent screen on authentication

revoke

If TRUE a user on logout will need to re-authenticate

Details

Call via shiny::callModule(googleAuth, "your_ui_name", login_text = "Login")

Value

A reactive authentication token

See Also

Other shiny module functions: googleAuthUI

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## Not run: 
options("googleAuthR.scopes.selected" = 
  c("https://www.googleapis.com/auth/urlshortener"))

shorten_url <- function(url){
  body = list(
    longUrl = url
 )
 
 f <- 
   gar_api_generator("https://www.googleapis.com/urlshortener/v1/url",
                     "POST",
                     data_parse_function = function(x) x$id)
                        
 f(the_body = body)
 
 }

server <- function(input, output, session){

  ## Create access token and render login button
  access_token <- callModule(googleAuth, 
                             "loginButton",
                             login_text = "Login1")

  short_url_output <- eventReactive(input$submit, {
    ## wrap existing function with_shiny
    ## pass the reactive token in shiny_access_token
    ## pass other named arguments
    with_shiny(f = shorten_url, 
               shiny_access_token = access_token(),
               url=input$url)
  })

  output$short_url <- renderText({

    short_url_output()

  })

}

## ui
ui <- fluidPage(
  googleAuthUI("loginButton"),
  textInput("url", "Enter URL"),
  actionButton("submit", "Shorten URL"),
  textOutput("short_url")
)

shinyApp(ui = ui, server = server)

## End(Not run)

yinscapital/googleAuthR-reference documentation built on May 3, 2019, 4:31 p.m.