>>> # Get all projects viewable by anonymous users.
... projects = jira.projects()
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Python27\lib\site-packages\jira_python-0.16-py2.7.egg\jira\client.py", line 941, in projects
r_json = self._get_json('project')
File "C:\Python27\lib\site-packages\jira_python-0.16-py2.7.egg\jira\client.py", line 1526, in _get_json
r = self._session.get(url, params=params, headers=self._options['headers'])
File "C:\Python27\lib\site-packages\requests-2.2.1-py2.7.egg\requests\sessions.py", line 395, in get
return self.request('GET', url, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.2.1-py2.7.egg\requests\sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests-2.2.1-py2.7.egg\requests\sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.2.1-py2.7.egg\requests\adapters.py", line 381, in send
raise ProxyError(e)
**requests.exceptions.ProxyError: Cannot connect to proxy. Socket error: Tunnel connection failed: 407 authenticationrequired.**
Can you please any one help me how to solve this issue.
Try This:
basic_auth = ('username', 'password')
options = {
'server': <server url>,
'proxies' : <proxy>,
'verify' : False,
}
jira = JIRA(options,basic_auth=basic_auth,validate=True)
should work.
I tried and it is working for me.
Make sure you have access to the project to acess the issue.
Related
I wrote some code that logs in with 2fa and a proxy and then gets some info and returns it. It is not finished yet but the login section will not work. Here is the code, if someone could tell me what is wrong I would greatly appreciate it. As a side note I am using a socks5 ipv6 proxy, not sure if it must be ipv4 but I couldn't find an answer. Obviously I have removed my credentials from the code but they are put where it is indicated.
Here is my code:
from instagrapi import Client
import uuid
client_session_id = str(uuid.uuid4())
settings = {
"uuids": {
"phone_id": "be60e0a9-7201-5492-da04-4f2b85b3b592",
"uuid": "be60e0a9-7201-5492-da04-4f2b85b3b592",
"client_session_id": client_session_id,
"advertising_id": "1c413050-795d-f321-eeb4-4962ca0a731c",
"device_id": "android-f4f80570fe070b5f"
},
"cookies": {},
"last_login": 1674240519.7862692,
"device_settings": {
"cpu": "h1",
"dpi": "640dpi",
"model": "C6503",
"device": "C6503",
"resolution": "1794x1080",
"app_version": "117.0.0.28.123",
"manufacturer": "Sony",
"version_code": "164321834",
"android_release": "4.2.2",
"android_version": 23
},
"user_agent": "Opera/9.80 (Android 4.2.2; Linux; Opera Mobi/ADR-1210241554; U; en-us) Presto/2.11.355 Version/12.10"
}
cl = Client(settings)
proxy = "socks5://username:password#127.0.0.1:30235"
cl.set_proxy(proxy)
seed = 'PUT SEED HERE'
code = cl.totp_generate_code(seed)
cl.login('USERNAME', 'PASSWORD', verification_code=code)
user_id = cl.user_id_from_username("instagram")
followers = cl.user_followers(user_id, 0)
print(followers)
cl.logout()
When I run it I get this error:
Traceback (most recent call last):
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\adapters.py", line 456, in send
conn = self.get_connection(request.url, proxies)
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\adapters.py", line 345, in get_connection
proxy = prepend_scheme_if_needed(proxy, "http")
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\utils.py", line 988, in prepend_scheme_if_needed
parsed = parse_url(url)
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\util\url.py", line 397, in parse_url
return six.raise_from(LocationParseError(source_url), None)
File "<string>", line 3, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: socks5://socks5://username:password#127.0.0.1:30235
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\NAME\Desktop\learning\app.py", line 41, in <module>
cl.login('USERNAME', 'PASSWORD', verification_code=code)
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\instagrapi\mixins\auth.py", line 371, in login
self.pre_login_flow()
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\instagrapi\mixins\auth.py", line 47,
in pre_login_flow
self.set_contact_point_prefill("prefill")
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\instagrapi\mixins\auth.py", line 147, in set_contact_point_prefill
return self.private_request("accounts/contact_point_prefill/", data, login=True)
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\instagrapi\mixins\private.py", line 451, in private_request
raise e
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\instagrapi\mixins\private.py", line 438, in private_request
self._send_private_request(endpoint, **kwargs)
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\instagrapi\mixins\private.py", line 288, in _send_private_request
response = self.private.post(
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 635, in post
return self.request("POST", url, data=data, json=json, **kwargs)
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\adapters.py", line 458, in send
raise InvalidURL(e, request=request)
requests.exceptions.InvalidURL: Failed to parse: socks5://username:password#127.0.0.1:30235
This is source code of set_proxy function:
def set_proxy(self, dsn: str):
if dsn:
assert isinstance(
dsn, str
), f'Proxy must been string (URL), but now "{dsn}" ({type(dsn)})'
self.proxy = dsn
proxy_href = "{scheme}{href}".format(
scheme="http://" if not urlparse(self.proxy).scheme else "",
href=self.proxy,
)
self.public.proxies = self.private.proxies = {
"http": proxy_href,
"https": proxy_href,
}
return True
self.public.proxies = self.private.proxies = {}
return False
as you can see, it seems your private proxy schema string has a problem. Check your proxy string, it should be same with: How to make python Requests work via SOCKS proxy
macOS 10.12.3 python 2.7.13 requests 2.13.0
I use requests package to send post request.This request need to login before post data.So I use request.Session() and load a logined cookie.
Then I use this session to send post data in cycle mode.
It is no error that I used to run this code in Windows and Linux.
Simple Code:
s = request.Session()
s.cookies = cookieslib.LWPCookieJar('cookise')
s.cookies.load(ignore_discard=True)
for user_id in range(100,200):
url = 'http://xxxx'
data = { 'user': user_id, 'content': '123'}
r = s.post(url, data)
...
But the program frequently (about every interval) crash, the error isAttributeError: 'module' object has no attribute 'kqueue'
Traceback (most recent call last):
File "/Users/gasxia/Dev/Projects/TgbookSpider/kfz_send_msg.py", line 90, in send_msg
r = requests.post(url, data) # catch error if user isn't exist
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 535, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 588, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 241, in _get_conn
if conn and is_connection_dropped(conn):
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/util/connection.py", line 27, in is_connection_dropped
return bool(wait_for_read(sock, timeout=0.0))
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/util/wait.py", line 33, in wait_for_read
return _wait_for_io_events(socks, EVENT_READ, timeout)
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/util/wait.py", line 22, in _wait_for_io_events
with DefaultSelector() as selector:
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/util/selectors.py", line 431, in __init__
self._kqueue = select.kqueue()
AttributeError: 'module' object has no attribute 'kqueue'
This looks like a problem that commonly arises if you're using something like eventlet or gevent, both of which monkeypatch the select module. If you're using those to achieve asynchrony, you will need to ensure that those monkeypatches are applied before importing requests. This is a known bug, being tracked in this issue.
I am running Neo4j 2.2.1 in ubuntu Amazon EC2 instance. When I am trying to connect through python using py2neo-2.0.7, I am getting following error :
py2neo.packages.httpstream.http.SocketError: Operation not permitted
I am able to access the web-interface through http://52.10.**.***:7474/browser/
CODE :-
from py2neo import Graph, watch, Node, Relationship
url_graph_conn = "https://neo4j:password#52.10.**.***:7474/db/data/"
print url_graph_conn
my_conn = Graph(url_graph_conn)
babynames = my_conn.find("BabyName")
for babyname in babynames:
print 2
Error message :-
https://neo4j:password#52.10.**.***:7474/db/data/
Traceback (most recent call last):
File "C:\Users\rharoon002\eclipse_workspace\peace\peace\core\graphconnection.py", line 39, in <module>
for babyname in babynames:
File "C:\Python27\lib\site-packages\py2neo\core.py", line 770, in find
response = self.cypher.post(statement, parameters)
File "C:\Python27\lib\site-packages\py2neo\core.py", line 667, in cypher
metadata = self.resource.metadata
File "C:\Python27\lib\site-packages\py2neo\core.py", line 213, in metadata
self.get()
File "C:\Python27\lib\site-packages\py2neo\core.py", line 258, in get
response = self.__base.get(headers=headers, redirect_limit=redirect_limit, **kwargs)
File "C:\Python27\lib\site-packages\py2neo\packages\httpstream\http.py", line 966, in get
return self.__get_or_head("GET", if_modified_since, headers, redirect_limit, **kwargs)
File "C:\Python27\lib\site-packages\py2neo\packages\httpstream\http.py", line 943, in __get_or_head
return rq.submit(redirect_limit=redirect_limit, **kwargs)
File "C:\Python27\lib\site-packages\py2neo\packages\httpstream\http.py", line 433, in submit
http, rs = submit(self.method, uri, self.body, self.headers)
File "C:\Python27\lib\site-packages\py2neo\packages\httpstream\http.py", line 362, in submit
raise SocketError(code, description, host_port=uri.host_port)
py2neo.packages.httpstream.http.SocketError: Operation not permitted
You are trying to access neo4j via https on the standard port for http (7474):
url_graph_conn = "https://neo4j:password#52.10.**.***:7474/db/data/"
The standard port for a https connection is 7473. Try:
url_graph_conn = "https://neo4j:password#52.10.**.***:7473/db/data/"
And make sure you can access the web interface via https:
https://52.10.**.***:7473/browser/
You can change/see the port settings in your neo4j-server.properties file.
I can't figure out why all of a sudden the below code that uses Asana's API generates the below SSL error. Something must have changed on my laptop, since it runs perfectly on my other computer.
from asana import asana
class Login(object):
def __init__(self):
api = 'API'
self.asana_api = asana.AsanaAPI(api, debug=False)
self.user_id = 7359085011308L
class Test(Login):
def Test(self):
Id = 2467584555313L
print self.asana_api.list_tasks(Id,self.user_id)
Traceback (most recent call last):
File "/Users/Chris/Dropbox/AsanaPullPush.py", line 75, in <module>
if __name__ == "__main__": main()
File "/Users/Chris/Dropbox/AsanaPullPush.py", line 72, in main
print Test().Test()
File "/Users/Chris/Dropbox/AsanaPullPush.py", line 15, in Test
print self.asana_api.list_tasks(Id,self.user_id)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/asana/asana.py", line 174, in list_tasks
return self._asana(target)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/asana/asana.py", line 74, in _asana
r = requests.get(target, auth=(self.apikey, ""))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/adapters.py", line 389, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm
We recently changed our SSL key in response to the Heartbleed bug you may have heard about. http://blog.asana.com/2014/04/heartbleed/
It looks like your laptop may not have the right SSL. See https://github.com/pypa/pip/issues/829 for discussion of a similar issue.
You should be able to check SSL version on the two machines with python -c "import ssl; print ssl.OPENSSL_VERSION". If indeed the laptop is behind, you'll need to update your python's SSL.
I try to connect to a jira dev sandbox through https but it comes up with an SSL23_GET_SERVER_HELLO:unknown protocol error
This is the error log/stack trace. I try both ports 8080 and 443 but no joy.
>>> from jira.client import JIRA
>>> options = {'server':'localhost:8080'}
>>> auth = ('username', 'password')
>>> jira = JIRA(options, auth)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ve/lib/python2.6/site-packages/jira/client.py", line 88, in __init__
self._create_http_basic_session(*basic_auth)
File "/home/ve/lib/python2.6/site-packages/jira/client.py", line 1369, in _create_http_basic_session
r = self._session.post(url, data=json.dumps(payload))
File "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 284, in post
return self.request('post', url, data=data, **kwargs)
File "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 241, in request
r.send(prefetch=prefetch)
File "/home/ve/lib/python2.6/site-packages/requests/models.py", line 638, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:480: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
>>> options = {'server':'localhost:443'}
>>> auth = ('username', 'password')
>>> jira = JIRA(options, auth)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ve/lib/python2.6/site-packages/jira/client.py", line 88, in __init__
self._create_http_basic_session(*basic_auth)
File "/home/ve/lib/python2.6/site-packages/jira/client.py", line 1369, in _create_http_basic_session
r = self._session.post(url, data=json.dumps(payload))
File "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 284, in post
return self.request('post', url, data=data, **kwargs)
File "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 241, in request
r.send(prefetch=prefetch)
File "/home/ve/lib/python2.6/site-packages/requests/models.py", line 631, in send
raise ConnectionError(sockerr)
requests.exceptions.ConnectionError: [Errno 110] Connection timed out
>>>
Try this:
from jira.client import JIRA
options = {'server':'localhost:8080'}
jira = JIRA(options)
jira = JIRA(basic_auth=('username', 'password'))
If it doesn't help, any chance the have OpenSSL conflicts?
When curl is linked against OpenSSL 0.9.8 and tries to access a server running OpenSSL 1.0.0, the SSL handshake fails with:
curl: (35) error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)
Got it now. Port 8080 was set up and was not a defauld for http connection whether as for https I used validation manipulation basically setting validate = False in the jira-python method body