Description Usage Arguments Value See Also Examples
View source: R/googleAuthR_deprecated.R
USe within a ui.R to render the login button generated by renderLogin
1 | loginOutput(output_name)
|
output_name |
Name of what output object was assigned in |
A login/logout button in a Shiny app
Other shiny auth functions: authReturnCode
,
createCode
,
gar_shiny_getAuthUrl
,
gar_shiny_getToken
,
gar_shiny_getUrl
,
reactiveAccessToken
,
renderLogin
,
revokeEventObserver
,
with_shiny
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 54 55 56 57 58 59 60 61 62 63 64 65 | ## Not run:
## in global.R
## create the API call function, example with goo.gl URL shortner
library(googleAuthR)
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)
}
## in server.R
library(shiny)
library(googleAuthR)
source('global.R')
shinyServer(function(input, output, session)){
## Get auth code from return URL
access_token <- reactiveAccessToken(session)
## Make a loginButton to display using loginOutput
output$loginButton <- renderLogin(session, access_token())
short_url_output <- eventReactive(input$submit, {
## wrap existing function with_shiny
## pass the reactive token in shiny_access_token
## pass other named arguments
short_url <- with_shiny(f = shorten_url,
shiny_access_token = access_token(),
url=input$url)
})
output$short_url <- renderText({
short_url_output()
})
}
## in ui.R
library(shiny)
library(googleAuthR)
shinyUI(
fluidPage(
loginOutput("loginButton"),
textInput("url", "Enter URL"),
actionButton("submit", "Shorten URL"),
textOutput("short_url")
))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.