question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[8.0] Allow using http_auth with RequestsHttpNode for custom authentication

See original GitHub issue

Using http_auth is deprecated for passing Tuple[str, str] and str but is useful for custom HTTP authentication with the Requests library. For example Kerberos and GSS are possible with this method. To allow for these to continue working we’ll continue setting requests.Session.auth = http_auth when used this way.

Reference: https://github.com/elastic/elasticsearch-py/pull/1776#issuecomment-953299419

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
naisanzaacommented, Feb 15, 2022

Error importing RequestsHttpConnection:

from elasticsearch import RequestsHttpConnection

Traceback (most recent call last):
  File "/Users/eric/venv/garbage/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3251, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-8-6f544e924cdd>", line 1, in <module>
    from elasticsearch import RequestsHttpConnection
ImportError: cannot import name 'RequestsHttpConnection' from 'elasticsearch' (/Users/eric/venv/garbage/lib/python3.9/site-packages/elasticsearch/__init__.py)

elastic-transport==8.0.1
elasticsearch==8.0.0
1reaction
james-henry-gitcommented, Sep 26, 2022

So what is the solution to this problem ? I’m still having the same issue, with ES 8.1.0 This stackoverflow post has an answer that says to downgrade from python package elasticsearch==8.0.0 to elasticsearch==7.13.4

FYI, for those struggling with using the requests module in Elasticsearch 8.x is hardly documented well, we shouldn’t need to thunk down versions, we just need to tell it to use RequestsHttpNode and set the appropriate variables.

import os
os.environ["https_proxy"] = "http://proxy_name:8080"
from elastic_transport import RequestsHttpNode
from elasticsearch import Elasticsearch
client = Elasticsearch(
    cloud_id = authkeys['cloud_id'], 
    api_key = authkeys['api_key'],
    node_class=RequestsHttpNode,
    )
Read more comments on GitHub >

github_iconTop Results From Across the Web

Welcome to Flask-HTTPAuth's documentation! — Flask ...
The following example application uses a custom HTTP authentication scheme ... Flask-HTTPAuth will allow access only if get_password(username) == password .
Read more >
How to create an Authentication Provider in Drupal 8
But what about if Basic Auth doesn't fit with your needs, well I will show you how to create a custom Authentication Provider....
Read more >
How do I use basic HTTP authentication with the python ...
You need to use a session object and send the authentication each request. The session will also track cookies for you: session =...
Read more >
Http Authentication
This simple example returns the username "user" and a password for every HTTP authentication interaction. A more realistic example would use the other...
Read more >
Authentication - Laravel - The PHP Framework For Web Artisans
The simplest way to implement a custom, HTTP request based authentication system is by using the Auth::viaRequest method. This method allows you to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found