Question

Basic Auth with 'basic token' instead of username password

  • 7 April 2020
  • 6 replies
  • 3069 views

Userlevel 1

The APi I am trying to connect to requires a header “authorization” “basic xxxxxxx” (where “xxxx” is a generated token).

 

When I select basic authentcation it requires a user and password, selecting API key allows me to add  the two fields that were used to generate the token needed in authorization header. Neither work.

 

How do I go about setting up an API connection that just uses an authorization header as indicated above?


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +12

Hi @antonvh - Are you building a custom app?

Userlevel 1

Yes I am,

Userlevel 7
Badge +12

@antonvh - Basic authentication requires that you calculate the base64 representation of `${username}:${password}` combination. This will be handled automatically for you if you set your authentication type to “basic”. You can leave the input fields empty.

Check out this example if you’re building a CLI app: https://github.com/zapier/zapier-platform-example-app-basic-auth/blob/master/authentication.js#L18

Userlevel 1

Thanks for the prompt response.

The API I am connecting to uses a “subdomain” field and “api key” to construct the base64 token and not user and password. I tried putting the domain string in the user field and the api token in the password field but it doesn’t work. There might be something else wrong so if the way I am doing it (user = domain and pw = api key) then I will have to dig deeper.

 

Userlevel 7
Badge +12

@antonvh - Ok, so in order to make sure this is the correct way to construct the Authorization header, have you tried to authenticate using the username = domain and password = API key in something like Postman? Do you mind to share a link to the API documentation?

Userlevel 7
Badge +11

Hi @antonvh!

Just wanted to check on this to see if the responses by @ikbelkirasan had helped you out, or whether you still needed some assistance here. Please let us know :)