Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • TRTH /
avatar image
Question by hello_world · May 05, 2020 at 10:26 PM · pythontrthv2token_authenticationmapping

Attempt to request Authentication Token fails with 401

This function is taken from the examples slightly modified:

def getAuthenticationToken(self, userName, password):
        authReqUrl = self.baseUrl + "Authentication/RequestToken"
        credentialsData = {'Credentials': {'Username': userName, 'Password': password}}

        r = requests.post(url=authReqUrl, json=credentialsData, headers=self.requestHeaders)

        if (r.status_code == 200):
            jsonResponse = json.loads(r.text.encode('ascii', 'ignore'))
            token = {'timestamp': datetime.datetime.now(), 'token': jsonResponse["value"]}
            with open('TRTH_token.pkl', 'wb') as handle:
                pickle.dump(token, handle, protocol=pickle.HIGHEST_PROTOCOL)
            return token
        else:
            print("ERROR: could not retrieve authentication token, check username and password:")
            print("Status code: ", r.status_code, "\nResponse:\n", r.text)
            sys.exit()

This returns the following response:

Status code:  401 
Response:
 {"error":{"message":"Invalid username or password"}}

The username and passwords sent as args are the ones corresponding to this website. I tried using both email and username, but neither work. Eventually, this is what I'm looking for; a simple mapping which requires authentication, therefore this question.

Thanks!

People who like this

0 Show 1
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
hello_world · May 06, 2020 at 08:05 PM 0
Share

My fault for not being thorough enough. Both this article and this metadata clearly indicate to contact a Thomson Reuters account manager for this issue. @Konstantin Pavlov had the same problem, as he describes in the comments of the article. Furthermore, the ThomsonReuters.Dss.Api.Authentication namespace specifies:

<Annotation Term="Org.OData.Core.V1.LongDescription" String="Talk to your DataScope representative about getting DataScope credentials. The API accepts the same credentials used for FTP and Web GUI."/>

Perhaps I could rephrase my question this way, who can I contact for DSS username and password? and how can I contact the representative? Any guidance on this is highly appreciated. Cheers!

2 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by zoya.farberov · May 06, 2020 at 08:09 PM

Hello @hello_world,

Please note that credentials used for this community are set at self-registration and anyone can register and be a member of this community, and obtain these creds.

TRTH and DSS credentials are assigned to customers, as part of their subscription to the product. Please contact you Refinitiv Account manager, if your organization has the product and you need help with credentials.

If you are looking to purchase or sign up for a trial, directly contact local Refinitiv sales team at https://www.refinitiv.com/en/contact-us for more information

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Answer by chavalit.jintamalit · May 06, 2020 at 01:33 AM

Hi @hello_world

I modified your code a little bit to make it executable.

And I can successfully get the token.

Code:

import requests
import json
import datetime

def getAuthenticationToken(userName, password):
        authReqUrl = "https://hosted.datascopeapi.reuters.com/RestApi/v1/Authentication/RequestToken"
        credentialsData = {'Credentials': {'Username': userName, 'Password': password}}

        headers = {
                    'Prefer': 'respond-async',
                    'Content-Type': 'application/json'
                }
        
        r = requests.post(url=authReqUrl, json=credentialsData, headers=headers)

        if (r.status_code == 200):
            jsonResponse = json.loads(r.text.encode('ascii', 'ignore'))
            token = {'timestamp': datetime.datetime.now(), 'token': jsonResponse["value"]}
            #with open('TRTH_token.pkl', 'wb') as handle:
            #    pickle.dump(token, handle, protocol=pickle.HIGHEST_PROTOCOL)
            return token
        else:
            print("ERROR: could not retrieve authentication token, check username and password:")
            print("Status code: ", r.status_code, "\nResponse:\n", r.text)
            sys.exit()


user = 'xxxxyyyy'
password = 'xxxxyyyy'
getAuthenticationToken(userName=user, password=password)



ahs.jpg (248.6 KiB)
Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
hello_world · May 06, 2020 at 01:41 PM 0
Share

Thanks for your reply @chavalit.jintamalit but it still doesn't work. I believe the credentials are simply incorrect because the username (email/user) and password with which I login into this community are the same sent as json, and the response (401) is always the same. This question talks about something similar, and the answer indicates towards a DSS username and password. Where can I get these? I mean, there is lack of documentation regarding to what username and password are required for any API. To my knowledge up to this extent there are developer community credentials, DDS credentials, Platform credentials, and whatsoever.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
12 People are following this question.

Related Questions

Python code to extract data.

I am accessing TRTH v2 data using API and using python as main language

Calls to TRTH Service Appear Slow

TRTH Python API - Queuing Time

How could I access Libre rate and centre bank rate from API

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges