Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add basic auth via requests library #16

Merged
merged 4 commits into from
Apr 19, 2021
Merged

Conversation

etoulas
Copy link
Contributor

@etoulas etoulas commented Apr 13, 2021

Requests can do basic auth out of the box.

requests.get('https://api.github.com/user', auth=('user', 'pass'))

This works also with POST requests.

Documentation: https://2.python-requests.org/en/master/user/authentication/#basic-authentication

@etoulas
Copy link
Contributor Author

etoulas commented Apr 13, 2021

@vvaezian: This PR would benefit from some additional testing!

@vvaezian
Copy link
Owner

@etoulas Thanks for the PR. I'll review it soon.

@vvaezian
Copy link
Owner

Is there a scenario where the current authentication cannot handle it and adding basic auth would make it possible?

@etoulas
Copy link
Contributor Author

etoulas commented Apr 14, 2021

Glad you asked @vvaezian. My Metabase instance is behind a reverse proxy that asks for basic auth. It's accepts the same credentials as Metabase.

This is what happens

  1. Make request to Metabase
  2. Basic auth on reverse proxy
  3. Login to Metabase instance
  4. Access API

My initial approach gave more flexibilty by letting the user provide any basic auth credentials. But for my use case it was enough to use the same credentials for the requests library.

@vvaezian vvaezian merged commit 280846f into vvaezian:master Apr 19, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants