harwee/IQOption-Api

Login not working?

EVAZA opened this issue · 4 comments

EVAZA commented

It seems IQ has changed something, login is not working any more...

me too @EVAZA , i have this error :
Traceback (most recent call last):
File "starter.py", line 170, in
start()
File "starter.py", line 140, in start
starter.create_connection()
File "starter.py", line 32, in create_connection
self.api.connect()
File "/usr/local/lib/python2.7/dist-packages/iqoptionapi/api.py", line 277, in connect
response = self.login(self.username, self.password) # pylint: disable=not-callable
File "/usr/local/lib/python2.7/dist-packages/iqoptionapi/http/login.py", line 30, in call
return self._post(data=data)
File "/usr/local/lib/python2.7/dist-packages/iqoptionapi/http/login.py", line 17, in _post
return self.send_http_request("POST", data=data, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/iqoptionapi/http/resource.py", line 25, in send_http_request
return self.api.send_http_request(self, method, data=data, params=params, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/iqoptionapi/api.py", line 101, in send_http_request
response.raise_for_status()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://iqoption.com/api/login

@EVAZA
ye couldn't login myself. Though my problem seemed to be with the websocket being closed, so i assume it didn't wait for a response or a socket to open. Added a simple time.sleep fix in the api.py get_instruments method.
it should look sth like this:
def get_instruments(self): time.sleep(0.25) for ele in self.instruments_categories: self.send_socket_message("sendMessage",{"name":"get-instruments","version":"1.0","body":{"type":ele}})
adjust the sleep amount accordingly, maybe its a bandwidth issue :P .
@Aleandro21 dont know if this will work for you, but i guess you can try it :D .

I also assume you dont need this line: api.start_socket_connection()
in the initial script cause this is called in the login method.

Here is a fix: in your login POST request, change the url: