HTTP Basic Auth with multiple Users

Hey Bubblers,

Can one of you explain how to Authenticate multiple users with HTTP Basic Auth? The API requires an Email (for Username) and API Token (for Password). All of my calls work great so that’s not the problem.

Thanks,
Daniel

Any ideas @emmanuel? I need to use this for https://timekit.io to work properly.

Any ideas @NigelG?

I think you will need to ask them to input their password (assuming email is the same as their account on your app), and then call …

https://api.timekit.io/v2/auth with email and password

And retrieve the api_token which you will then need to store against the user, and use this in subsequent calls.

I’ve got all of that down except for making calls with the user’s API Token. I don’t see how I’d use the token for calls. There is no header/parameter where I could enter their tokens.

if only “Basic” meant “Simple” in this case :slight_smile:

It should be in the header …

Key = Authorization
Value = Basic the@email.com:123apikey456

You will have to base64 encode the “the@email.com:123apikey456” part … but that is possible using a little bit of javascript (I use an api to do this, but that was pre-plugins).

So now you have a long string of stuff … So your value in the Authorization key will be something like…

Basic 897dadhsjkad7as8d7as9

1 Like

Haha, I tried this WITHOUT base64 encode so I’ll give it a go. Really appreciate the guidance!

It doesn’t seem to make a difference. I must be making an error somewhere. Maybe I don’t understand the process of Authenticating a user with the HTTP Basic Auth method.

Have you used the API Connector in this way before?

Yes I have.

It might be worth contacting Timekit themselves.

From the documentation it looks like you need to create the API key from within your app by creating a User. So by doing a POST to /users ?

I know others have used Timekit before, so maybe worth a search as well. Remember to put Timekit-App in your header.

Had a quick play and can get it to work in Postman…

Make sure you are encoding the email:apikey properly.

Works in Bubble OK too…



As I said, my guess that it is your Base64 encode that isn’t working.

1 Like

Haha, your the best. My problem was I didn’t set the API to (None or self-handled). The Authorization Key works now.

Really appreciate the help!!!

@NigelG What API do you use for this?

I created my own in webtask.io

https://wt-nigel_godfrey-gmail_com-0.run.webtask.io/base64atob
https://wt-nigel_godfrey-gmail_com-0.run.webtask.io/base64btoa

Just a few lines of code to encode and decode and you get an API you can call from Bubble.

var base64url = require(‘base64-url’);

module.exports = function(context, cb) {
cb(null, base64url.decode(context.query.qtext));
}

var base64url = require(‘base64-url’);

module.exports = function(context, cb) {
cb(null, base64url.encode(context.query.qtext));
}

1 Like

Cool, thanks!