Retrieving events

Has anything changed the lasted few days, definitely less that a week?

I had a python program to retrieve from notehub, events over the past 24 hours. It stopped working a couple of days ago. I ran it directly from my laptop to check and I am getting a 400 status from my request.

Code below

headers = CaseInsensitiveDict()
headers[“Content-Type”] = “application/json”

data = ‘{“username":"xxxxxxx”, “password”: “xxxxx”}’

resp = requests.post(url, headers=headers, data=data)

print(resp.status_code)

Randy

Hello Randy,

You’re using session tokens as the authentication method for the Notehub API.

A couple of days ago, we have introduced a new authentication mechanism using personal access tokens: New in Notehub: Personal Access Tokens - Blues - Product Updates

These changes are aimed at improving an overall system security by giving our users capabilities to manage their API tokens in Notehub. However, in order to be able to manage these tokens, we introduced a restriction on the number of tokens each user may have in a given moment of time. The current limit is set at 10.

Does your script use the /auth/login endpoint to generate a new token each time you run it? If yes, my guess is that it hits the limit of available tokens.

If my guess is correct, you need to:

  1. create a new API token in the Notehub UI (using these instructions)
  2. copy the API token
  3. adapt your script to always use this token in your Notehub API requests. As a security precaution, we advise that you read the token from an environmental variable you create on your machine and don’t put it directly into your script.

Please let me know if this helps. If not, we’ll continue debugging.

Cheers,
Marcin

1 Like

Thanks, I will look into this tomorrow and let you know.

randy

Your suggestion fixed the problem.

I was creating tokens dynamically. I deleted all but a couple of tokens and created a new one and added it into my program and the program worked as expected.

Thanks for your hlp

Randy

3 Likes