chenxiaolong / RSAF

An Android Storage Access Framework document provider for rclone
GNU General Public License v3.0
199 stars 6 forks source link

Google Drive how to specify service_account_file location? #57

Closed pjhfggij closed 4 months ago

pjhfggij commented 4 months ago

How do you specify service_account_file field for RSAF? Normally it should point to a .json file, but due to differences in the way file systems work on android the normal path doesn't seem to work?

e.g. this doesn't work:

[remote1]
type = crypt
remote = remote1-crypt:folder
password = XXX
password2 = XXX

[remote1-crypt]
type = drive
scope = drive
service_account_file = /data/data/com.termux/files/home/.config/rclone/service-account-1.json
root_folder_id = XXX
shared_with_me = true
pjhfggij commented 4 months ago

I couldn't figure out how to get service_account_file to work, but following this forum post (where everyone somehow called this option differently) and with some chatgpt prompt (which incorrectly suggested writing json blob on multiline I've got it to work in this format:

[mydrive]
type = drive
scope = drive
service_account_credentials = {"type": "service_account","project_id": "your-project-id","private_key_id": "your-private-key-id","private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n","client_email": "your-service-account-email","client_id": "your-client-id","auth_uri": https://accounts.google.com/o/oauth2/auth,"token_uri": https://oauth2.googleapis.com/token,"auth_provider_x509_cert_url": https://www.googleapis.com/oauth2/v1/certs,"client_x509_cert_url": https://www.googleapis.com/robot/v1/metadata/x509/your-service-account-email}
pjhfggij commented 4 months ago

I've reopened it, in case someone might know why service_account_file didn't work?

chenxiaolong commented 4 months ago
service_account_file = /data/data/com.termux/files/home/.config/rclone/service-account-1.json

This doesn't work because Android does not allow apps to access the private data directories of other apps. There are 3 ways to handle this:

pjhfggij commented 4 months ago

Oh of course, sorry I forgot about it, because Termux also shares it's files via "Storage Access Framework" and it always appears in the file picker. Thanks for explaining that.

That's tangential to the question, but do you know if there is any way to "mount" a folder shared via Storage Access Framework locally as a regular folder? That could also solve this issue without having to copy files. I'm struggling with this exact problem as well right now trying to get RSAF to work with music players, which don't have support for SAF?

chenxiaolong commented 4 months ago

No problem!

do you know if there is any way to "mount" a folder shared via Storage Access Framework locally as a regular folder?

It would be so much nicer if Android has some way of doing this, but unfortunately there's no way.

pjhfggij commented 4 months ago

cool, thanks for confirming. indeed a shame. I'll have to piece together a custom pipeline in termux just to play me some music from google drive rclone lsf music: --max-depth 1 | shuf | while IFS= read -r i; do rclone cat "music:$i" | mpv -; done