n1nj4z33 / iqoptionapi

IQ Option API 4.x (Python 2.7) The project is obsolete and is not supported because of problems with access to IQ Options in Russia
119 stars 542 forks source link

API doesn't work inside another app? #71

Closed milteven12 closed 6 years ago

milteven12 commented 6 years ago

Hello, I'm trying to put an GUI (Tkinter module) on my iqoption script, it just has buttons for call, put, change balance to real, and change to demo but I having some problems, when I click on the button to change balance, an error occur: (This is the server websocket response on IDLE)

2017-11-10 17:16:54,161 https://iqoption.com/api/profile/changebalance
2017-11-10 17:16:54,969 {"msg":1510341414426,"name":"timeSync"}
2017-11-10 17:16:55,225 <Response [401]>
2017-11-10 17:16:55,235 {"isSuccessful":false,"message":["Not authorized"],"result":[]}
2017-11-10 17:16:55,249 {'Server': 'nginx', 'Date': 'Fri, 10 Nov 2017 19:16:54 GMT', 'Content-Type': 'text/html; charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Set-Cookie': 'ssid=0907c7640aa607a60b57183847a37d43; expires=Sun, 10-Dec-2017 19:16:54 GMT; Max-Age=2592000; path=/; domain=.iqoption.com, ssid=0907c7640aa607a60b57183847a37d43; expires=Sun, 10-Dec-2017 19:16:54 GMT; Max-Age=2592000; path=/; domain=iq-option.com, ssid=0907c7640aa607a60b57183847a37d43; expires=Sun, 10-Dec-2017 19:16:54 GMT; Max-Age=2592000; path=/; domain=iqoption.com, __uat=0; expires=Fri, 10-Nov-2017 18:16:54 GMT; Max-Age=0; path=/', 'X-Front-Host': 'fe-api-06'}
2017-11-10 17:16:55,271 <RequestsCookieJar[<Cookie ssid=0907c7640aa607a60b57183847a37d43 for .iqoption.com/>]>
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Casa\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
    return self.func(*args)

Does anyone know why I'm getting a "Not authorized" message?

Thank you for your time, have a good day!

milteven12 commented 6 years ago

Feedback: To acquire authorization we use api.connect(), if your function is returning a "Not authorized" message you need to use api.connect() again INSIDE the function.

I don't know why is necessary to do this procedure for the function.