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

pyvo user agent in case of authenticated queries #263

Open
almicol opened this issue May 14, 2021 · 2 comments
Open

pyvo user agent in case of authenticated queries #263

almicol opened this issue May 14, 2021 · 2 comments
Labels
Milestone

Comments

@almicol
Copy link

almicol commented May 14, 2021

The user agent reported by pyvo v1.1 when performing an anonymous TAP query is:

python-pyvo/1.1

while instead when I perform an authenticated query the user agent is set to:

python-requests/2.25.1

It is a pity to lose the pyvo information, the user agent statistics I derive are therefore affected.

My code, with authentication, looks like this:

mysession = requests.Session()
mysession.headers['Authorization'] = "Bearer " + mytoken
tap = vo.dal.TAPService(TAPURL, session=mysession)
query = 'select table_name from TAP_SCHEMA.tables'
tables = tap.search(query)

It would seem useful if the user agent set by the python requests library could be overwritten by pyvo.
But I'd consider this very low priority, it is just for you to know...

@andamian andamian added the bug label May 18, 2021
@andamian andamian added this to the Future milestone May 18, 2021
@andamian
Copy link
Contributor

Hmm. We need to look into this. Thanks @almicol

@andamian
Copy link
Contributor

@almicol - finally had a chance to look at this. The thing is that you are creating the session yourself so you "own" it in this case. pyvo could set it but NOT if the session is part of an application that wants to set its own user agent. Maybe pyvo could set it ONLY if it's not set already? Not sure about that either.

If you want to create a pyvo session you could use pyvo.utils.http.get_session() and that session has the pyvo user agent set. It is however a bit buried 3 levels deep and not documented. Maybe we should bring it a bit forward (i.e. expose it directly in pyvo.utils?

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

No branches or pull requests

2 participants