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

Add support of service account #9

Closed
gregorth opened this issue Jun 3, 2019 · 23 comments
Closed

Add support of service account #9

gregorth opened this issue Jun 3, 2019 · 23 comments
Labels
feature New feature or request

Comments

@gregorth
Copy link

gregorth commented Jun 3, 2019

This library looks really awesome but the one thing that stopped me before using it, it lacks of support service account. Any changes to implement it?

@omarryhan
Copy link
Owner

Thanks!

Unfortunately, I'm very busy these days + I don't have much use for most of Google Cloud Products. This might change in a month or two, but for now, I'm open to merging pull requests.

If you have the time and willing to help me implement this feature, please let me know, so we can work on it together.

Cheers :)

@omarryhan omarryhan added the feature New feature or request label Jul 12, 2019
@nicksspirit
Copy link

nicksspirit commented Jul 18, 2019

Hey I would love to work on this with you!!! how do I start?

@omarryhan
Copy link
Owner

Cool! Thanks @OdinTech3.

What extra interfaces you think we'll need in order to fully support service accounts?

@nicksspirit
Copy link

@omarryhan Were you referring to me?

@omarryhan
Copy link
Owner

@OdinTech3 Yes :)

@nicksspirit
Copy link

nicksspirit commented Jul 20, 2019

I am not well versed with the details of the google api codebase, but this is something i am researching and want to really take on, but need to familiarize myself with your codebase and google's.
Where could I reach you if i need to clarify things, is your email that you put on github good?

@omarryhan
Copy link
Owner

Sure, take your time. I need to do some research as well.

Yes omarryhan@gmail.com is my email. Feel free to email me there. If you want me to create a public Discord chat or something similar, I'm also open to that.

@omarryhan
Copy link
Owner

I made a public Trello board for this feature. Let me know if you would like to join so I can add you as a member. https://trello.com/b/pOLVsBFI/aiogoogle-service-accounts-feature

@nicksspirit
Copy link

nicksspirit commented Jul 20, 2019 via email

@omarryhan
Copy link
Owner

Cool, what's your email?

@nicksspirit
Copy link

nicksspirit commented Jul 20, 2019 via email

@thehesiod
Copy link

awesome lib! I'm going to try to get this rolling as I've hit enough resource issues trying to get our systems working with the original google api which is a giant resource hog.

@thehesiod
Copy link

btw may want to move this to aio-libs group

@thehesiod
Copy link

I'm conflicted between using this, or something which inherits and overrides behavior from the google-python API client for reason of the various tweaks it has added over time. How much was the original API client code integrated into this project? I'm worried because of stuff like data.py, which is supposed to come dynamically.

@omarryhan
Copy link
Owner

omarryhan commented Jan 13, 2020

Hey @thehesiod, thanks for chiming in.

The 2 data.py files I added, are only here for convenience. You can still load your own 1. auth discovery document 2. discovery discovery document. In the auth module, I try to borrow as much code as I can from Google's already existing auth libraries. Namely: the google-auth package & https://github.com/googleapis/google-auth-library-python.

@omarryhan
Copy link
Owner

Hi, @gregorth @ivankosenko @MrMrRobat @dm0 @thehesiod @OdinTech3

I'll try to put some hours into this feature this week. Can you tell me your use cases? What APIs you most certainly need, what APIs you can live without and what are not that important?

It seems like we might be getting Asyncio support in Google's main auth library soon: googleapis/google-auth-library-python#465. Will the features introduced in this PR kill the need for adding service accounts support here? I personally don't think so. I think that we still need a way to make the Aiogoogle object understand service account creds and be able to accept it this way:

async with Aiogoogle(service_account_creds=service_accound_dict) as aiogoogle:
    ...

And obviously, also be able to grab and refresh an access token using the service account creds. Generally, I think that this is the most important feature to add right now. Features like getting the default service account creds from a compute or app engine can wait or maybe not even needed at all because we can always use Google's auth lib.

Any thoughts?

@thehesiod
Copy link

I've made my own async version of the Google apis which has more or less full functionality by building on top of the official api. I'm going to try to see if my employer will allow me to make them public and will report back

@thehesiod
Copy link

ok so i got approval, its going through legal

@Omeryl
Copy link

Omeryl commented Aug 29, 2020

@thehesiod did you ever get it through Legal?

@thehesiod
Copy link

@Omeryl just pinged again, the signal I got last time was positive. We've been using it w/o issues for awhile now. I even added credential caching support back

@booya
Copy link

booya commented Oct 1, 2020

I found a way to get this working on a GCE instance with a service account. I'm using the google metadata server to get an auth token, and passing it into the Aiogoogle instance. The token needs to be refreshed periodically, so it's wrapped in a loop which checks the token's expiry time, and refreshes once the token lifetime is < 1200 seconds. This feels a bit hacky, but seems to work well enough after some preliminary testing. Maybe it's useful for anyone hoping to use aiogoogle on a GCE/GKE instance with a service account.

https://gist.github.com/booya/e10554cb6302a0a4b43dcdd16a9e4147

@omarryhan
Copy link
Owner

Hey guys, I just added basic service account support in version 1.0.0.

Right now, you can authenticate as a service account in two ways:

  1. Load the service account key as a Python dict and pass it to Aiogoogle as service_account_creds.
  2. Point the GOOGLE_APPLICATION_CREDENTIALS environment variable at the location of the JSON key file.

We're still missing automatic detection from:

  1. Google Cloud SDK
  2. Google App Engine environment
  3. Google Compute Engine environment

Adding them should be easy though, if someone's up for the task.

You can find more info here in the docs.

@omarryhan
Copy link
Owner

I'm going to close this. Please open a new feature request if there's a specific service-account feature that you want.

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

No branches or pull requests

6 participants