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

Support for GCP Service Account authentication? #398

Open
jakebiesinger opened this issue Nov 28, 2018 · 3 comments
Open

Support for GCP Service Account authentication? #398

jakebiesinger opened this issue Nov 28, 2018 · 3 comments

Comments

@jakebiesinger
Copy link

Hi!

New to Bravado. We use GCP service accounts extensively and I'd like to combine them with Bravado. Is this currently possible?

GCP provides a client library that's also based on Requests, but you have to use their AuthenticatedSession object to do so, which seems at odds with your direct usage of requests.Request.

Thoughts?

@jakebiesinger
Copy link
Author

At first blush, it looks like we could simply provide an optional requests.Session object, one which we'd generate from Google's client library. We could provide the session to the RequestsClient constructor:

self.session = requests.Session()

@macisamuele
Copy link
Collaborator

Checking https://cloud.google.com/compute/docs/tutorials/python-guide looks like the GCP python client exposes Google Cloud Platform apis via methods and not Swagger specs, so it shouldn't be usable with bravado.

@jakebiesinger: I'm probably misunderstanding your request, so I would ask if you could describe (maybe with a snippet) what are you trying to achieve.

@jakebiesinger
Copy link
Author

Sorry this was unclear.

I'm not trying to call Google APIs as if they were Swagger endpoints. Rather, I'm trying to call one of our own APIs (which is a Swagger endpoint), but to have that call authenticated as a GCP Service Account.

The way non-swagger APIs would normally do this is to grab credentials for the service account and make POST or GETs using Google's own requests-based client library. https://google-auth.readthedocs.io/en/latest/user-guide.html#requests

Since you generate a fresh Session there in the linked line 106, I'm suggesting that you instead let us optionally pass in Google's AuthorizedSession, which is, after all, just a subclass of requests.Session (instead of creating a new one).

I'll try this out in a PR if I get a chance in the next day or two.

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