thoughts on swapping to use google.auth.transport.requests.AuthorizedSession
I wrote an async impl of googleapiclient + google-auth and in my impl I use the AuthorizedSession as the "http" param. There are just two small issues in doing this is the reversal of the method, url params, and change of name of data and body params. It seems like by using AuthorizedSession it would make the code simpler and avoid code duplication.
in particular in lieu of the http/credentials params to https://github.com/googleapis/google-api-python-client/blob/main/googleapiclient/discovery.py#L178 for example
I also thought that would be a good idea, it would also allow you to set session-level headers such as X-Goog-User-Project. I hit what I thought was an odd issue when using service discovery to build and use a Data Catalog Resource.
When creating an HttpRequest object for looking-up an Entry and listing tags for an entry, I get HTTP 403 SERVICE_DISABLED because it can't determine the billing project. Example:
from googleapiclient.discovery import build
credentials, project = google.auth.default()
service = build(serviceName="datacatalog", version="v1", credentials=credentials)
http_request = service.entries().lookup(linkedResource='<RESOURCE_URI>')
#http_request = service.projects().locations().entryGroups().entries().tags().list(parent=<ENTRY_ID>)
response = http_request.execute() # This will error.
The only way I could find to fix this is to explicitly set the project header before calling execute()
req.headers['X-Goog-User-Project'] = '<MY PROJECT>'
This doesn't occur with any of the other resources I've used for Data Catalog. I'm not sure if this is a separate issue, or expected behaviour.