Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drive_auth() for a specific folder in Google Drive #464

Open
bdschwartzkopf opened this issue Oct 25, 2024 · 1 comment
Open

drive_auth() for a specific folder in Google Drive #464

bdschwartzkopf opened this issue Oct 25, 2024 · 1 comment

Comments

@bdschwartzkopf
Copy link

Hi,
I have been searching hi and low for an answer to my problem but have not found anything.

I am trying to output ggplot plots to specific Google Drive folders but am not having any luck. I imagine it is the scope I am using in drive_auth().

I am not interested in allowing full access to my Google Drive (i.e., scope="drive"), and only want to access certain folders. I tried scope="drive.file" hoping this would work, but I have not been able to save any output to a specific folder.

this is what my drive_upload code looks like:
drive_upload(media="Output/Plots/plot.jpeg",
path=as_id("1OGVyempjkFEH7IPqC0D9-lncpqwPN-Pf"),
name="plot",
type="jpeg")

Is allowing access to only certain folders possible?

@jennybc
Copy link
Member

jennybc commented Oct 28, 2024

Is allowing access to only certain folders possible?

The short, probably somewhat oversimplified answer is "no".

At a very high-level, I think you have 2 ways forward:

  • Use a service account for whatever script or data product we're talking about here. And grant that service account the necessary permissions on the specific folder. And grant it nothing else.
  • Maybe something is possible with the drive.appdata and drive.appfolder scopes? But honestly I can't see how that would really work because Google's notion of an "app" is so far from how we R users use the APIs. A constant source of pain. This pain is related to your experience of drive.file not doing what you want either.

The significance of various scopes is explained here:
https://developers.google.com/drive/api/guides/api-specific-auth

But, no, I am not aware of any way to connect the concept of scopes and a specific folder in Drive. This sort of restricted access will always have to be accomplished by some doing the work as some sort of user or agent and then applying the limits/privileges you want to that user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants