Python API - Error code 407

Hi,

I'm trying to set the Eikon Python API on my computer in order to retrieve data directly in Python instead of using the Excel add-in.

I installed the necessary Python package and I use the following code to test (I found it in the codebook examples).

import refinitiv.dataplatform.eikon as ek

ek.set_app_key('my-app-key')

df,err = ek.get_data(['PEUP.PA', 'EUR=', 'JPY='], ['BID','ASK'])

df

Unfortunately, I get the following error:

Error code 407 | Client Error: Proxy Authentication Required - <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Could you please help me solve the issue ? it seems it comes from the proxy. Is there a config file I should update to provide the proxy address and my credentials ?

I try to run the Python API on the same computer where Eikon is installed. I get this issue independently of the app_key I input (if it's the correct one or a dummy one).

Thank you in advance.

Thomas

Best Answer

  • Jirapongse
    Answer ✓

    @thomas.tr.rempala

    The HTTP response 407 is Proxy Authentication Required. The Eikon Data API connects to the Eikon via the localhost (127.0.0.1). I assume that the following error was sent by your internal proxy server.

    2022-04-20 12:59:26,432 P[14800] [MainThread 8624] HTTP request response 407: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    ...
    <div class="longExplanation">
        Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.
    </div>

    You should contact your local IT support team to verify internal proxy settings, as mentioned by my colleague.

    You can also run the following code to verify the connection.

    import requests
    r = requests.get('http://127.0.0.1:9060/api/status')
    print(r.status_code)
    print(r.content)

    The output is:

    1650865413169.png


Answers

  • Hi @thomas.tr.rempala,

    Please follow the steps in the Eikon Data API(Python) Troubleshooting to verify the problem.

    And, you can enable logging in to Eikon Data API by using the following command.

    ek.set_log_level(1)

    You can share the log file when the problem occurred.

    Note that the Eikon Desktop/Refinitiv Workspace also has to be running on the same machine as mentioned in the troubleshooting guide.

  • Hi @thomas.tr.rempala,

    Also, the error indicates that the request has not been applied because it lacks valid authentication credentials for a proxy server that is between the browser and the server that can access the requested resource. IT Team needs to look at your Proxy Server or SSO/Kerberos Server to make sure that it is sending out the request packet to our server with your credentials attached to it. So please, contact the local IT support team to verify the problem once as well.


    Thanks,

  • Hi @Shadab Hussain

    I followed the instructions on the troubleshooting page, everything seem to work except the check of the logs (I cannot change the configuration of the eikon log however, so I could not check the step: Locate "APIPROXY" and "API Proxy is available on port XXXX" in the log file. By default, the port is 9060).


    I run the following code:

    import eikon as ek
    ek.set_log_level(1) #This is to enable log detail
    ek.set_app_key(app_key='xxxxxxxxxxxxxxxx') #A valid app key is required.


    I get the following error (extract):

    2022-04-20 12:59:26,357 P[14800] [MainThread 8624] Reset a Desktop session with new app_key
    2022-04-20 12:59:26,373 P[14800] [MainThread 8624] Unlock login_event for streaming session 0 due to stop streaming call
    2022-04-20 12:59:26,392 P[14800] [MainThread 8624] Send GET request to http://x.x.x.x:9060/api/status to detect API Proxy...
    2022-04-20 12:59:26,407 P[14800] [MainThread 8624] Request to http://x.x.x.x:9060/api/status
        headers = {'x-tr-applicationid': 'xxxxxxxxxxxxxxxx'}
        params = None
    2022-04-20 12:59:26,432 P[14800] [MainThread 8624] HTTP request response 407: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    ...
    <div class="longExplanation">
    Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.
    </div>
    ...