Authenticate on Botpress API


#1

Hi team

When running locally, I can GET to for instance http://localhost:3000/api/botpress-broadcast/broadcasts to see the list of broadcasts. On the production server (Heroku) though, I get the response 401 Unauthorized. I’ve attempted Basic Auth with the admin username & password, but no luck.

Can you help?
Thanks
Matthew


#2

Hey, I’ve answered within github-issue: https://github.com/botpress/botpress/issues/1030


#3

Being a bear of smallish brain it took me a little while to figure out that I could get that Bearer token from localStorage (in the Application Tab in Chrome Developer Tools) after logging into the Botpress instance.


#4

Hey @alex how would we do this programmatically? I tried sending a request to /login with the username and password to get the token. I thought I would use that to do the other API requests (like scheduling for our case). But even though I pass in username as admin and password as password, it keeps giving me bad username / password. I wonder if there is another way to do it?


#5

I’m using a very old version of Botpress (10.2.0), but anyways I was able to get the token with bp.security.login(username, password)and then I appended the token to a couple axios calls to test, and it worked! I havent gone through everything yet, but wanted to let you know about the progress