not able to login

rk13
Hi
I am using the following code to connect from my desktop( 127.0.0.1 is the redirect url i have provided )
--------------------------------
from kiteconnect import KiteConnect

# Initialise.
kite_api_key = "my api key"
kite = KiteConnect(api_key=kite_api_key)
kite_secret_key = "my secret key"
kite_request_token = "request token obtained from url"

# Assuming you have obtained the `request_token`
# after the auth flow redirect by redirecting the
# user to kite.login_url()
try:
user = kite.request_access_token(request_token=kite_request_token, secret=kite_secret_key)
# kite.set_access_token(user["access_token"])

except Exception as e:
print("Authentication failed", str(e))
raise

-------------------------------

i get the following error - what could be the issue pls.

user = kite.request_access_token(request_token=kite_request_token, secret=kite_secret_key)
File "build\bdist.win-amd64\egg\kiteconnect\__init__.py", line 210, in request_access_token
self.contains_replacement_characters) in (
File "build\bdist.win-amd64\egg\kiteconnect\__init__.py", line 439, in _post
return prefix + super(BeautifulSoup, self).decode(
File "build\bdist.win-amd64\egg\kiteconnect\__init__.py", line 489, in _request
  • Kailash
    What's your api_key?
  • rk13
    rk13 edited June 2016
    ws3oikfn1zc5xbbt
  • Vivek
    @rk13 Can you please share full error stacktrace?
  • rk13
    ('Authentication failed', 'Gateway connection error')
    Traceback (most recent call last):
    File "C:\Users\kravishankar\workspace\testing\KiteConnect_Test.py", line 15, in
    user = kite.request_access_token(request_token=kite_request_token, secret=kite_secret_key)
    File "build\bdist.win-amd64\egg\kiteconnect\__init__.py", line 210, in request_access_token
    self.contains_replacement_characters) in (
    File "build\bdist.win-amd64\egg\kiteconnect\__init__.py", line 439, in _post
    return prefix + super(BeautifulSoup, self).decode(
    File "build\bdist.win-amd64\egg\kiteconnect\__init__.py", line 489, in _request

    kiteconnect.exceptions.ClientNetworkException: Gateway connection error
  • Vivek
    @rk13 Please check whether the request token you are obtaining after redirected is right. You can try on browser manually and use the request token to verify.
  • rk13
    how to check it manually?
  • rk13
    @vivek, is there any specific URL format to use for verifying the request token manually?
  • rk13
    when i try to get the request token , the URL says success
    https://127.0.0.1/?status=success&request_token=xx

    where as the browser throws this error message:
    The connection to 127.0.0.1 was interrupted while the page was loading.

    The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
    Please contact the website owners to inform them of this problem.

    is the process correct? Anything missing?
  • Kailash
    The redirect happens because the login is successful.

    You're getting an error because 127.0.0.1 is your local system's IP and you are not running a web server on it. You can simply copy the request_token from the URL and use it with the API.
  • rk13
    Hi Kailash, that is what I have been doing. But it always gives the below error , i tried in multiple computers to check if there are any issues with proxy setting. Same error
    Traceback (most recent call last):
    File "C:\Users\kravishankar\workspace\testing\KiteConnect_Test.py", line 15, in
    ('Authentication failed', 'Gateway connection error')
    user = kite.request_access_token(request_token=kite_request_token, secret=kite_secret_key)
    File "build\bdist.win-amd64\egg\kiteconnect\__init__.py", line 210, in request_access_token
    self.contains_replacement_characters) in (
    File "build\bdist.win-amd64\egg\kiteconnect\__init__.py", line 439, in _post
    return prefix + super(BeautifulSoup, self).decode(
    File "build\bdist.win-amd64\egg\kiteconnect\__init__.py", line 489, in _request

    kiteconnect.exceptions.ClientNetworkException: Gateway connection error
  • Kailash
    ClientNetworkException means your system was unable to reach https://api.kite.trade. This could be a network/proxy issue. We have no recorded or reported downtime on api.kite.trade.

    Can you try sending CURL requests to see if they are going through?
  • rk13
    I get the following error when i try connecting to "https://api.kite.trade". any solution pls?

    requests.exceptions.ProxyError: HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 400 Bad Request',)))

  • Kailash
    Kailash edited June 2016
    > Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 400 Bad Request',)
    Looks like you're request is going through some sort of a proxy and that's failing? Did you try a CURL request from your system to see if it goes through?
  • rk13
    I am using Windows and dont find curl in my machine. is there any other option i can try?
Sign In or Register to comment.