-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
GDrive: Fix fieldNotWritable, Add SupportSharedDrive, Add service_account method #512
base: main
Are you sure you want to change the base?
Conversation
&drive.File Size => fieldNotWritable error
SupportsAllDrives(true) => all action IncludeItemsFromAllDrives(true) => List
Check localConfigPath == "" on NEWGDriveStorage()
This reverts commit cd9c56e.
how do you select a shared drive as target? is giving the service account access to a specific shared folder that you end up using a folder? (total guess) |
server/storage/gdrive.go
Outdated
return nil, err | ||
var httpClient *http.Client | ||
|
||
if strings.Contains(string(b), `"type": "service_account"`) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's have a separate cli param for service account file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param like --gdrive-type=service / oauth2?
or we can actually check in json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oauth2
{ "installed": { "client_id": "clientid", "project_id": "projectname", "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_secret": "clientsecret" } }
Service Account
{ "type": "service_account", "project_id": "projectname", "private_key_id": "keyid", "private_key": "-----BEGIN PRIVATE KEY-----\nKEYSECRET\n-----END PRIVATE KEY-----\n", "client_email": "[email protected]", "client_id": "clientid", "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/transfersh%40projectname.iam.gserviceaccount.com" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param like --gdrive-type=service / oauth2?
or we can actually check in json.
param like gdrive-client-json-filepath
: gdrive-service-account-json-filepath
only one of the two can be set
in the factory you can translate this to a single param with the path and a new param for the type (service account/oauth2): it is up to you
i think we can get folder id from basedir |
JWTConfigFromJson to getGDriveClientFromServiceAccount
be00bb8 if basedir == "root", then user's drive root folder is used to store files. |
About this, There is no problem even if we receive the auth-type with cli or automatically identify it with credentials.json. Or, it seems that there will be no problem even if it is made to work both when auth-type is entered or not. |
server/storage/gdrive.go
Outdated
return nil, err | ||
var httpClient *http.Client | ||
|
||
if strings.Contains(string(b), `"type": "service_account"`) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param like --gdrive-type=service / oauth2?
or we can actually check in json.
param like gdrive-client-json-filepath
: gdrive-service-account-json-filepath
only one of the two can be set
in the factory you can translate this to a single param with the path and a new param for the type (service account/oauth2): it is up to you
err = ioutil.WriteFile(rootFileConfig, []byte(s.rootID), os.FileMode(0600)) | ||
if err != nil { | ||
return err | ||
func (s *GDrive) checkRoot() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a breaking change.
basedir is the name of the folder to be created in the gdrive, rootID is the id of the folder once created and that we save. the two carry two different information.
if we replce rootID value with basedir value:
- we don't create the folder
- current installations have to change the value that they pass to basedir, to use instead rootID
I guess you meant this change to be the way to select a shared drive, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!
I changed basedir to insert folder id, to select rootID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot accept a breaking change, sorry
you have to find another way to provide the sharedfolder to use and the basedir as it was
Added gdrive-auth-type |
@@ -169,6 +169,12 @@ var globalFlags = []cli.Flag{ | |||
Value: "", | |||
EnvVar: "GDRIVE_CLIENT_JSON_FILEPATH", | |||
}, | |||
cli.StringFlag{ | |||
Name: "gdrive-auth-type", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this way you pass gdrive-client-json-filepath
when it's a gdrive-service-account-filepath
indeed
also it's a breaking change, I cannot accept it, sorry :(
you can add gdrive-service-account-filepath
, check that only this or gdrive-client-json-filepath
is set (and at least one of them), and set the authType
value to pass to the factory: https://github.com/dutchcoders/transfer.sh/pull/512/files#diff-8e494a434a8037b6c0b888e25b2baae7618fe65e792d4a155dadd096e9350667R488
please, remember to change the name of the param in the factory to something generic, like gdriveCredentialsFilepath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please. see my latest comments :)
No description provided.