Announcement

Collapse
No announcement yet.

Problem with login

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with login

    Hello.
    My English isn't perfect so be forgiving please
    I've got problem with login to betfair api. I downloaded and installed "requests" library. I'm using python 3.4. Here's my code:
    PHP Code:
    import requests

    payload 
    'username=XXXXXXXX&password=XXXXXXXX'
    headers = {'X-Application''XXXXXXXX''Content-Type''application/x-www-form-urlencoded'}
     
    resp requests.post('https://identitysso.betfair.com/api/certlogin'data=payloadcert=('client-2048.crt''client-2048.key'), headers=headers)
     
    if 
    resp.status_code == 200:
      
    resp_json resp.json()
      print (
    resp_json['loginStatus'])
      print (
    resp_json['sessionToken'])
    else:
      print (
    "Request failed."
    Of course I generated key and certificate in openSSL and added .crt file to betfair profile.

    When i'm trying to run thic code, Python is returning that:
    Traceback (most recent call last):
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\connectionpool .py", line 544, in urlopen
    body=body, headers=headers)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\connectionpool .py", line 341, in _make_request
    self._validate_conn(conn)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\connectionpool .py", line 762, in _validate_conn
    conn.connect()
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\connection.py" , line 238, in connect
    ssl_version=resolved_ssl_version)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\util\ssl_.py", line 254, in ssl_wrap_socket
    context.load_cert_chain(certfile, keyfile)
    FileNotFoundError: [Errno 2] No such file or directory

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\adapters.py", line 370, in send
    timeout=timeout
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\connectionpool .py", line 597, in urlopen
    _stacktrace=sys.exc_info()[2])
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\util\retry.py" , line 245, in increment
    raise six.reraise(type(error), error, _stacktrace)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\packages\six.p y", line 309, in reraise
    raise value.with_traceback(tb)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\connectionpool .py", line 544, in urlopen
    body=body, headers=headers)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\connectionpool .py", line 341, in _make_request
    self._validate_conn(conn)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\connectionpool .py", line 762, in _validate_conn
    conn.connect()
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\connection.py" , line 238, in connect
    ssl_version=resolved_ssl_version)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\packages\urllib3\util\ssl_.py", line 254, in ssl_wrap_socket
    context.load_cert_chain(certfile, keyfile)
    requests.packages.urllib3.exceptions.ProtocolError : ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:\Users\KARAD\Desktop\KAROL\Betting\bet.py", line 6, in <module>
    resp = requests.post('https://identitysso.betfair.com/api/certlogin', data=payload, cert=('client-2048.crt', 'client-2048.key'), headers=headers)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\api.py", line 99, in post
    return request('post', url, data=data, json=json, **kwargs)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\api.py", line 49, in request
    response = session.request(method=method, url=url, **kwargs)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\sessions.py", line 461, in request
    resp = self.send(prep, **send_kwargs)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
    File "C:\Python34\lib\site-packages\requests-2.5.3-py3.4.egg\requests\adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
    requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
    I was searching for answer in Google more than 2 hours and I didn't find nothing similar.

    Please help me.

  • #2
    Hi skorp,
    Have you been able to resolve this? I'm getting the same error but I'm struggling to find a resolution as you.

    Thanks,
    Nav

    Comment


    • #3
      Yes, fantastic. This is a topic that excites me. geometry dash

      Comment

      Working...
      X