question

Upvotes
Accepted
15 0 1 4

Python refinitiv.data Unable to log on. Status 403

Hi team,

I are trying to move over from Refinitiv Data Platform Library to the refinitiv.data==1.3.1 library. I placed the machine ID, appkey and password in the configuration file. When running: rd.open_session()

I get an error: An error occurred while requesting URL('https://api.refinitiv.com/auth/oauth2/v1/token'). ProxyError('403 Forbidden')

I was able to debug the session and included the debug from the session debug_log.txt. I tried to check the API key on the API playground API Playground (refinitiv.com), but the site does not respond.

Can you help me out here?

#technologyrefinitiv-data-platformpython api
debug-log.txt (2.7 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @VFM

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,
AHS

Upvotes
Accepted
17.6k 82 39 63

Hi @VFM

The above error where you see "Required scopes" and "Available scopes", that tells you what data services you are permissioned for. As you can see, when you requested for pricing snapshots, you don't have access to the "trapi.data.pricing.read" scope, which is the pricing snapshot. You appear to be given streaming data and other basic services such as Search and Symbology.

The first thing I would do is try a historical pricing example. You should get back a similar error as above with a different scope that you don't have. Because you only require pricing snapshot and historical pricing, and not streaming, you can providing these details to your account manager and they should be able to help get you access to the data you need.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
17.6k 82 39 63

Hi @VFM

It appears you need to apply some settings to your environment to work with your corporate proxy. For example:

import os
os.environ['HTTP_PROXY']="http://127.0.0.1:8080"
os.environ['HTTPS_PROXY']="http://127.0.0.1:8080"
os.environ['SSL_CERT_FILE'] = "C:\\Users\\U8009686\\.mitmproxy\\mitmproxy-ca.pem"

You can find more details in this question.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
15 0 1 4

Hi Nick,

I found out that the proxy settings on our development machine have changed. After adjusting for that - the session no returns the status opened correctly.

Next - we try to query some default data:

df = rd.get_data(
        universe=['GBP=', 'EUR=', 'JPY='],
        fields=['BID', 'ASK'])

I get an error on this:

Exception has occurred: RDError: Error code -1 | Cannot load the list of associated URLs from https://api.refinitiv.com/streaming/pricing/v1/ for apis.streaming.pricing.endpoints.main endpoint

Please see the attached debug log debug_log_get_data.txt.

Can you help us with this?

Kind regards,

Merijn

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @VFM

Can you attach the debug log?

Certainly. Sorry - I thought I had attached that too the original post. debug_log_get_data.txt

Upvotes
1.3k 3 2 4

Hi @VFM ,

You mention:

  • "I found out that the proxy settings on our development machine have changed. After adjusting for that - the session no returns the status opened correctly."
    => Did you applied Nick's solution ? (adding in your code os.environ['HTTP_PROXY']=...)

  • "After adjusting for that - the session no returns the status opened correctly."
    I assume your logs contain successful response on token request sent to https://api.refinitiv.com/auth/oauth2/v1/token.
    => Could you confirm ?

If you're using a desktop session, that could explain the error you have on rd.get_data() call, but it seems you're using a platform session (as http requests are sent directly to the platform).

If you switch to a desktop session and set HTTP_PROXY and HTTPS_PROXY as global environment variables to let Eikon or Workspace application to use it, it could fix your issue.
=> Could you add these environment variables then test again with a desktop session ?

If you still facing to the same error:

[2023-08-28T11:15:15.544413+02:00] - [ERROR] - [sessions.platform.rdp.0] - [11628] | OpenUniverseStreams-Thread_0
An error occurred while requesting URL('https://api.refinitiv.com/streaming/pricing/v1/').
ConnectError('[Errno 11001] getaddrinfo failed')

we'll need more context to understand what could block HTTP request to retrieve websocket urls for streaming, especially API Proxy logs (see in Troubleshooting guide)

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
15 0 1 4

Hi Pf,

We are using using platform session. We have the proxy settings in place. The session opens correctly but is not returning data. No streaming data and no snapshots.

In a previous try I got this error - indicating that we dont have the correct scope:

Error code -1 | Insufficient scope for key=/data/pricing/snapshots/v1/, method=GET. Required scopes: {'trapi.data.pricing.read'} Available scopes: {'trapi.cfs.claimcheck.read', 'trapi.data.symbology.advanced.read', 'trapi.search.metadata.read', 'trapi.metadata.read', 'trapi.auth.cloud-credentials', 'trapi.streaming.pricing.read', 'trapi.data.symbology.read', 'trapi.search.explore.read'} Missing scopes: {'trapi.data.pricing.read'}

I followed the troubleshooting guide for the refinitiv data library (RD Library version 1.3.1). My code is as follows:

import refinitiv.data as rd
    os.environ["RD_LIB_CONFIG_PATH"] = "D:/project/refinitiv/Configuration"            
    os.environ['HTTP_PROXY'] = 'http://xxxx:xx'
    os.environ['HTTPS_PROXY'] = 'http://xxxx:xx'
    
    print (rd.__version__)
    rd.open_session()
    rd.get_data(['LSEG.L'])

Now, I only get the second error:

Error code -1 | Cannot load the list of associated URLs from https://api.refinitiv.com/streaming/pricing/v1/ for apis.streaming.pricing.endpoints.main endpoint.

I enabled logging and attached the log output to my previous post. See attached again the debug logging. debug_log_get_data_2.txt.

Please note that the goal is to move away from streaming rates - and only retrieve snapshots. I don't want to open a stream, and than snap it - but use the correct end point for snapshot data.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
17.6k 82 39 63

Hi @VFM

I can't explain the reason why you are receiving the issue with regards to not loading streaming endpoints - perhaps it may be a permission issue. I will let @pf address this.

If you don't even need streaming but only pricing snapshots, there is a service within RDP that provides this. Within the library, you can using the pricing interface. You can find an example here:

Example.DataLibrary.Python/Examples/2-Content/2.02-Pricing/EX-2.02.01-Pricing-Snapshot.ipynb at main · Refinitiv-API-Samples/Example.DataLibrary.Python (github.com)


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi Nick, I am looking only for snapshot, and historical data. I don't want streaming data.

When I try this code - I get the more descriptive error:


error.png

Can you please check what is wrong here?

Kind regards,

Merijn

error.png (65.0 KiB)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.