-
Notifications
You must be signed in to change notification settings - Fork 1.3k
gdrive: support Google Service accounts #3269
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3269 +/- ##
=======================================
Coverage 91.30% 91.30%
=======================================
Files 141 141
Lines 8582 8594 +12
=======================================
+ Hits 7836 7847 +11
- Misses 746 747 +1
Continue to review full report at Codecov.
|
|
For the record: PyDrive2 1.4.4 has been released. |
|
@Maxris Any progress on this? |
|
@efiop I believe, it should be evaluated/tested by @shcheklein |
|
@shcheklein yes, it seems it doesn't help to solve limits issues, since Service Account impersonate some another user in domain and the limits are the same. |
Locally user specified path to p12 key and PyDrive automatically retrieves new access_token for Service Account after old one is expired. The difference to the auth for normal Google account is that in addition to an access_token a refresh_token is obtained, and PyDrive automatically retrieves a new access_token by using a refresh_token value. |
|
@Maxris not sure I understood the last part about refresh tokens and differences, could you please elaborate a bit?
what would the use case for this? automation? like in CI/CD or something?
what are we missing here? |
Yes, use case is to run tests on Travis with Service Account.
p12 key with custom password to do auth with Service Account from Iterative's G Suite and secure way (probably, one another env var) to pass custom password into PyDrive.ServiceAuth() |
|
@Maxris do service accounts have their own GDrive space? could you please elaborate on that difference in the token refresh mechanism, please? I still don't get it. |
No, Service account is a "resource" which has permissions to access other resources. This PR was tested with following flow https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority . As I understand, Service account receives access to any domain's data on behalf of any domain's user, but the access scope for this Service account can be limited to list of desired access scopes (for example, only
For usual Google drive user generated For Service account generated btw, in that Google's doc they warn: |
|
@Maxris Ok, makes sense. I checked the page and it looks like there is an option to not involve user into this 2LO vs 3LO. Don't you think for automation and testing purposes it would be easier to use 2LO from that doc? I don't see a need to impersonate someone through a service account, at least it does not look superior to the regular service account. Unless I'm missing something again. |
Good point! Another even more important thing is that PyDrive expects all 3 following params to be available https://github.com/iterative/PyDrive2/blob/master/pydrive2/auth.py#L146 |
bedae84 to
2068196
Compare
|
Once iterative/PyDrive2#11 is merged, it should be sufficient to set secured |
25919e4 to
c209498
Compare
c209498 to
38dcca7
Compare
yeah, if you put them in the schema, no need to define upper case constants anymore, just use strings, check similar cases in the gdrive.py |
dvc/remote/gdrive.py
Outdated
|
|
||
| GDRIVE_SERVICE_ACCOUNT_EMAIL = "gdrive_service_account_email" | ||
| GDRIVE_SERVICE_ACCOUNT_P12_FILE_PATH = "gdrive_service_account_user_email" | ||
| GDRIVE_SERVICE_ACCOUNT_USER_EMAIL = "gdrive_service_account_p12_file_path" |
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 comment - no need to do separate constants
shcheklein
left a comment
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.
looks great overall, check the only comment regarding the constants
|
@shcheklein this PR is not yet ready, need to setup Service Account and set Travis env var. |
|
@shcheklein should be ready to be merged |
|
@Maxris travis failed, PTAL. |
2e22601 to
8441ca5
Compare
|
@shcheklein thanks! Have fixed value of Travis env var and GDrive tests are passing now. There are still random failures of S3 tests (happen on all DVC Travis builds). |
|
S3 issues fixed, restarted the tests for this PR. Let's see. |
|
@efiop I think should be good to merge! :) |
iterative/PyDrive2#7 should be merged first
Introduces
gdrive_service_account_email,gdrive_service_account_user_emailandgdrive_service_account_p12_file_pathDVC config params to support authorization with Google Service accounts.Introduced config params are independent from
client_idandclient_secretconfig paramsUpdate:
iterative/PyDrive2#11 should be merged first
Introduces
gdrive_user_service_accountDVC config param disabled by default.