MarkEdmondson1234 / googleAuthR

Google API Client Library for R. Easy authentication and help to build Google API R libraries with OAuth2. Shiny compatible.
https://code.markedmondson.me/googleAuthR
Other
175 stars 51 forks source link

Switch to Google Identity Services? #220

Open gbultman opened 2 years ago

gbultman commented 2 years ago

What goes wrong

When running the demo Sample Google Sign-In app, name, email, and image do not populate. I've set up the people API and enabled the scopes below in the google developer console as well. I'm not sure if it's related to this:

Beginning April 30th, 2022 new applications must use the Google Identity Services library, existing apps may continue using the Platform Library until the deprecation date. https://developers.google.com/identity#google-sign-in

I tried this in a fresh install of the chromium browser with no ad blockers or script blockers.

In the browser console, I get the following: Uncaught : details: "You have created a new client application that uses libraries for user authentication or authorization that will soon be deprecated. New clients must use the new libraries instead; existing clients must also migrate before these libraries are deprecated. See the [Migration Guide](https://developers.google.com/identity/gsi/web/guides/gis-migration) for more information." error: "idpiframe_initialization_failed"

Steps to reproduce the problem

To reproduce this you'll probably need to create a brand new project


`library(shiny)
library(googleAuthR)
library(jsonlite)

Sys.unsetenv("GAR_CLIENT_JSON")
Sys.unsetenv("GAR_CLIENT_WEB_JSON")
options(googleAuthR.verbose=2)
gar_set_client(
    web_json = "client_secret.json",
               scopes = c("https://www.googleapis.com/auth/userinfo.email",
                          "https://www.googleapis.com/auth/userinfo.profile"),
    activate = "web"
)

options(shiny.port=1221)

ui <- fluidPage(

    titlePanel("Sample Google Sign-In"),

    sidebarLayout(
        sidebarPanel(
            googleSignInUI("demo")
        ),

        mainPanel(
            with(tags, dl(dt("Name"), dd(textOutput("g_name")),
                          dt("Email"), dd(textOutput("g_email")),
                          dt("Image"), dd(uiOutput("g_image")) ))
        )
    )
)

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

    sign_ins <- shiny::callModule(googleSignIn, "demo")

    output$g_name = renderText({ sign_ins()$name })
    output$g_email = renderText({ sign_ins()$email })
    output$g_image = renderUI({ img(src=sign_ins()$image) })

    observe({
        req(sign_ins()$name)

        print("This works")

    })

}

shinyApp(ui, server)`

## Expected output

Something populated in the Name, Email, and Image

## Actual output
Still Blank

Before you run your code, please run:

`> runApp()
ℹ 2022-08-25 14:11:01 > Setting web client.id from  client_secret.json
ℹ 2022-08-25 14:11:01 > 
options(googleAuthR.scopes.selected=c(' https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/userinfo.profile ')) 
options(googleAuthR.client_id='  ') 
options(googleAuthR.client_secret='  ') 
options(googleAuthR.webapp.client_id=' XXXXXX.apps.googleusercontent.com ') 
options(googleAuthR.webapp.client_secret=' XXXXXX ')`

## Session Info

`> sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] jsonlite_1.8.0    googleAuthR_2.0.0 shiny_1.7.1      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8.3     compiler_4.2.0   bslib_0.3.1      pillar_1.7.0    
 [5] later_1.3.0      jquerylib_0.1.4  tools_4.2.0      digest_0.6.29   
 [9] memoise_2.0.1    lifecycle_1.0.1  gargle_1.2.0     tibble_3.1.7    
[13] pkgconfig_2.0.3  rlang_1.0.2      cli_3.3.0        rstudioapi_0.13 
[17] curl_4.3.2       fastmap_1.1.0    withr_2.5.0      httr_1.4.3      
[21] askpass_1.1      fs_1.5.2         sass_0.4.1       vctrs_0.4.1     
[25] rappdirs_0.3.3   glue_1.6.2       R6_2.5.1         fansi_1.0.3     
[29] magrittr_2.0.3   promises_1.2.0.1 ellipsis_0.3.2   htmltools_0.5.2 
[33] assertthat_0.2.1 mime_0.12        xtable_1.8-4     httpuv_1.6.5    
[37] utf8_1.2.2       openssl_2.0.0    cachem_1.0.6     crayon_1.5.1    `
MarkEdmondson1234 commented 2 years ago

Yes this needs to be deprecated. Now I suggest looking at shinyauth package for server auth or firebase package for client auth.

gbultman commented 2 years ago

Thank you, Mark.

Greg