Commit 519467a8 authored by Aqeel Padaria's avatar Aqeel Padaria

include google auth in function directly to remove dependency on additional file

parent 9b109807
......@@ -32,7 +32,59 @@ server = shinyServer(
function(input, output, session) {
source(paste0(directory,"/google_auth.R"),local = T)
email_access<<-
c("@gramener.com")
get_auth_info=function (id = "me")
{
url <- sprintf("https://www.googleapis.com/plus/v1/people/%s",
id)
g <- googleAuthR::gar_api_generator(url, "GET")
req <- g()
user<- req$content
email=user$emails$value
auth="bad"
for(i in 1:length(email_access)){
if(grepl(email_access[i],email)) auth="good"
}
profile=list(displayName=user$displayName,fullname=paste(user$name$givenName,user$name$familyName,sep=" "),
email=email,imageurl=user$image$url,auth=auth)
profile
}
options(googleAuthR.scopes.selected = c("https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"))
options("googleAuthR.webapp.client_id" = "1063850569928-ktni7ff0ef0avt21611240hj6oi8jrkq.apps.googleusercontent.com")
options("googleAuthR.webapp.client_secret" = "5NJfGlsEArtEC0_MhZzeH9pe")
access_token <- callModule(googleAuth, "googleauth",login_class = "btn btn-primary",
logout_class = "btn btn-primary", login_text = "Log In",
logout_text = "Log Out",access_type="offline")
output$token<-renderText({
googleAuthR::gar_token_info()
})
#
## to use in a shiny app:
user_details <- reactive({
at=access_token()
if(!is.null(shiny::isolate(at))){
#print("not null")
if(!is.null(at$credentials$access_token)){
#print("good token")
at_back<<-at
}else{
#print("bad token")
at=at_back
}
with_shiny(get_auth_info, shiny_access_token = at)
}else{
return(NULL)
}
})
#source(paste0(directory,"/google_auth.R"),local = T)
observe({
user<<-user_details()
if(is.null(user)){
......@@ -242,7 +294,7 @@ server = shinyServer(
modname <- dataSelect()
original <- read.xlsx(datasetName, sheet = paste("d", modname, sep = "_"), colNames = TRUE)
original <- read.xlsx(datasetName, sheet = paste("d", modname, sep = "_"), colNames = TRUE, , check.names = FALSE)
original$date <- as.Date(original$date, origin = "1899-12-30")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment