ClaudioZandonella / trackdown

R package for collaborative writing and editing of R Markdown (or Sweave) documents in Google Docs.
https://ClaudioZandonella.github.io/trackdown/
GNU General Public License v3.0
214 stars 15 forks source link

Tracker V1.5.0 with GoogleDrive 2.0.0 refuses .qmd files #63

Open Scott-Akenhead opened 1 year ago

Scott-Akenhead commented 1 year ago

We wish to use Quarto over Rmarkdown because we want to use a journal template (PLoS ONE). Abandoned hope of collaborative development in Posit Cloud because of cost. Trackdown: “Create globally. Render locally.” seems perfect. Tried to follow instructions re issue #57 for Quarto and Trackdown.

remove.packages("googledrive") install.packages("~/Downloads/googledrive_2.0.0.tar.gz", repos = NULL, type = "source") remotes::install_github("claudiozandonella/trackdown", build_vignettes = TRUE); ─ building ‘trackdown_1.5.0.tar.gz’ library(trackdown) upload_file('OSO_Smolt_L_W.qmd', gpath='OSO SOX Primaries/1. Missing Ages/Paper and Parts/Smolts') ── Uploading files to Google Drive ────────────────────────────── Error: OSO_Smolt_L_W.qmd not supported file type (only .Rmd or .Rnw) 😢

ClaudioZandonella commented 1 year ago

Hi @Scott-Akenhead,

Thank you for reporting the issue. I like the slogan "Create globally. Render locally"😉

Can you please check that the loaded version of trackdown is 1.5.0 ?

To do that please restart the R-studio session and run the command packageVersion("trackdown")

If the correct version is loaded, there should be no problems.

PS. sorry for the late reply, my time schedule was a mess in thelasst mouths

ClaudioZandonella commented 1 year ago

Hi @Scott-Akenhead,

I just released version 1.5.1 that fixed compatibility with the new version of googledrive. Please let me know if the issue is not fixed!

Scott-Akenhead commented 1 year ago

Thanks! Updated: trackdown 1.5.1, googledrive 2.1.0. Then upload_file(“testTrackdown.qmd”) gets me to Sign in - Google. Great! Thenceupon, alack and alas: This app is blocked. This app tried to access sensitive info in your Google Account. To keep your account safe, Google blocked this access A cul-de-sac? No. RTFM!! Followed your careful instructions through a complicated, bewildering process; including install of gargle and usethis. But see attached snaps. Result: This app is blocked. My plan: (1) never do this again. (2) wait for TrackDown + Google authentication to get out of Testing mode. (3) wait for you to leverage GoogleSheets4 which plays nice. (4) continue to work. alone. in the dark. cold. frightened.

No response required.

Choose account - Trackdown R Package Developer Info
ClaudioZandonella commented 1 year ago

Hi @Scott-Akenhead,

Thank you for your answer and sorry for your troubles. You are right, setting up the authentication process is not easy and straightforward. It requires knowing a little bit about how Google API works and there are many steps to follow to get everything right. For this reason, I tried to provide very detailed documentation but is easy to miss some points.

Don't give up! you are only one step away from setting everything correctly 😉

Quick Answer

The message reported indicates that trackdown is not using the credentials of the app you created but is still using the internal ones. You can not use the internal credentials as the maximum number of users has already been achieved (more details in the next section). This issue is documented here https://claudiozandonella.github.io/trackdown/articles/oauth-client-configuration.html#app-credentials

To check the current auth configuration, run the command trackdown::trackdown_oauth_client()

trackdown::trackdown_oauth_client()
<gargle_oauth_client>
name: trackdown-rpackage         <---- check the name
id: <id-app>
secret: <REDACTED>
type: installed

If in the name filed you get trackdown-rpackage and not the name of your newly created app, it means you are using the wrong credentials.

To change the credentials, run the following command indicating the path to the JSON file with your credentials. More information are provided here https://claudiozandonella.github.io/trackdown/articles/oauth-client-configuration.html#users-authentication-in-r

trackdown::trackdown_auth_configure(path = "path/to/downloaded/json")

The JSON file is the file you download after following all the instructions for creating your own Client App credentials (https://claudiozandonella.github.io/trackdown/articles/oauth-client-configuration.html#creating-a-client-app-in-google-cloud-console). This file provides the credentials of your app.

Now if you are correctly using your credentials (run again trackdown::trackdown_oauth_client() to check) you are able to use trackdown.

If you still have problems please do not hesitate to contact me again! I am more than happy to help get everything done. I know the whole process is complicated. Unfortunately, I can not further simplify it at the moment (info below), but I hope you approach it as a great opportunity to learn more about how R - Google APIs integration works!

Details Answer

The first thing I want to point out is that, regardless of the threatening message

"This app is blocked. This app tried to access sensitive info in your Google Account. To keep your account safe, Google blocked this access"

there is nothing to be afraid of. Below I explain why, but first a brief summary of how Google APIs work.

Google APIs are services provided by Google allowing to automatically perform actions (e.g., upload/download documents, edit documents, etc.). These actions are usually done manually by users through Google interfaces (e.g., Maps, Drive, Doc, etc), but we can write code to automatize these actions.

Google APIs are used by many apps and software o interact with services provided by Google. This is what is done also by R packages such as GoogleSheets4, gmailr, as well as trackdown. These packages use Google APIs to perform specific actions. For example in the case of trackdown, actions are used to upload/download documents to users' Google Drive and highlight part of the text in the documents.

Note, Google does not allow anyone to use its API but you need to register your app.

Of course, the ideal solution would be to register trackdown to allow everyone to use the package. This is actually what we did. However, when you first register an app, Google allows only a limited number of users (i.e., 100). After that, a further validation process is required to make the app available to anyone.

We applied for the validation process, however, we did not pass it. It is a complicated process (all automated without anyone providing help or feedback on how to solve the problems). Our problem is that Google requires a web application for each app. But trackdown is an R package! We do not have a web application. After many requests without any answer from Google (except automated answers "Thanks for your question, please provide the web application" 😅). I am thinking of creating a shiny app interface. However, this is not straightforward it requires a lot of work (and not even sure it would be enough to pass the validation). So, regarding

(2) wait for TrackDown + Google authentication to get out of Testing mode.

sorry, currently I paused this to fix the bugs as creating a completely dedicated shiny app will require a very long time. I am very sorry for that, I would love to work on that right now but I can develop the package only in my free time. I am waiting for the summer holidays to see if I can make any progress on this.

Now you may wonder, "Wait, packages like GoogleSheets4 work without problems!". Yes, you are right. The reason is that all packages linked to tidyverse uses the app credentials of Tidyverse (see https://www.tidyverse.org/google_privacy_policy/).

Other packages are kindly invited to do not use their credentials (see the last paragraph https://www.tidyverse.org/google_privacy_policy/#policies-for-authors-of-packages-or-other-applications ).

So,

(3) wait for you to leverage GoogleSheets4 which plays nice.

trackdown can not use the same credentials.

I contacted people working at the development of tidyverse asking how they managed to pass the Google verification without a web application. They answered that it was difficult for them as well. They were rejected several times, but finally, they got some support from internal people at Google as they are the RStudio / "The Tidyverse Team".

Of course, as you may guess, it is quite different if it is me (a completely random person) asking for support or RStudio / "The Tidyverse Team".

So again I am not that positive about the possibility to pass the Google verification.

The current solution is to ask all users to obtain their own credentials. I know it is not ideal, but by providing detailed documentation and help, I try to make it as smooth as possible (https://claudiozandonella.github.io/trackdown/articles/oauth-client-configuration.html)

So,

(4) continue to work. alone. in the dark. cold. frightened.

please do not give up! I know is tough. It took many trials before understanding all the google API and gargle jargon to me as well. But after struggling a little bit I hope all pieces will come together😉

Again please do not hesitate to report further issues, I am really happy to help