question

Upvotes
Accepted
1 0 0 1

Lipper API - Token Errors

Hi, we receive different token errors when we want to extract data via API from Lipper: Token Error 400, Token Error 401, Token Error 403


Could you please explain what these errors mean? In all cases we get no data.

rdp-apiapilipper
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 @maximilian.mayrl ,

Could you please provide the code you use. (please also remove the credentials out of the code)

Upvotes
Accepted
47.4k 111 44 60

@maximilian.mayrl

You may need to log the error message from the body of the response message.

For more information, please refer to the Limitations and Guidelines for the RDP Authentication Service article.

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
782 2 1 1

@maximilian.mayrl , Is this a trail license? If so, maybe you can check if it's trail period is expired. If it is a normal paid license, did that user recently added or modified his/her service subscription? I am using the RDP Funds API and I have no issue encountered today.

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.

@b.lee
We have a normal paid license and the subscription user was not changed recently. The problem is that everything works just fine locally and not stable on the server. Sometimes we get Token Error 400 and 401 there.

Upvotes
1 0 0 0
SCOPE = "trapi
TOKEN_ENDPOINT = "https://api.refinitiv.com/auth/oauth2/v1/token"
expires_at = time.time()

auth_data = {"username": pen.settings.LIPPER_USERNAME, "password": pen.settings.LIPPER_PASSWORD, "grant_type": "password","scope": SCOPE, "takeExclusiveSignOnControl": "true"
}

refresh_data = {"refresh_token": lipper_refresh_token, "username": pen.settings.LIPPER_USERNAME, "grant_type": "refresh_token"
}

def get_token():
    global lipper_token, expires_at, lipper_refresh_token, rest_token_error_messages
    # global datascope_token
    if lipper_token == '' or expires_at < time.time():
        if lipper_refresh_token == '':
            respond = requests.post(TOKEN_ENDPOINT, headers = {"Accept": "application/json"}, data = auth_data, auth = (CLIENT_ID, CLIENT_SECRET))
        else:
            respond = requests.post(TOKEN_ENDPOINT, headers = {"Accept": "application/json"}, data = refresh_data, auth = (CLIENT_ID, CLIENT_SECRET))

        if respond.status_code != 200:
            return None
        else:
            respond_dict = respond.json()
            lipper_token = respond_dict['access_token']
            lipper_refresh_token = respond_dict['refresh_token']
            refresh_data['refresh_token'] = lipper_refresh_token
            expires_at = time.time() + int(respond_dict['expires_in']) - 10
            SCOPE = respond_dict['scope']
            auth_data['scope'] = SCOPE
    return lipper_token
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 @raksina.samasiri
There is the code we use for getting a token. It works without problems locally and only from time to time on the server.