Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to use 'Postman' and having trouble setting Basic access authentication Headers

Tags:

rest

api

postman

I have an API endpoint that I am trying to test with the google app: 'Postman'. I need to set the headers which use 'Basic authentication'. I am not sure what should go in 'Header: Value'

This is how the admin said the headers should be set: "The head value is the word 'Basic' followed by your org name and your Api key separated by a colon and base64 encoded."

I have tried numerous things but I am not getting it quite right. The error I get is "Message: Token not set".

like image 297
fresh5447 Avatar asked Aug 22 '15 15:08

fresh5447


People also ask

How do you pass basic authentication in header in Postman?

Basic auth Basic authentication involves sending a verified username and password with your request. In the request Authorization tab, select Basic Auth from the Type dropdown list. Enter your API username and password in the Username and Password fields. For additional security, store these in variables.

How do you set up Auth in Postman?

To do this, go to the authorization tab on the collection, then set the type to Bearer Token and value to {{access_token}}. Make sure the authorization details for each endpoint are configured to "inherit auth from parent" and saved in the correct location.

How do I pass my username and password Authorization header Postman?

Enter the postman for the Username and password for the Password field. Then, click on Send. The Response code obtained is now 200 OK, which means that our request has been sent successfully. We can also carry out Basic Authentication using the request Header.


2 Answers

Your header field should look like this:

Header : Authorization

Value : Basic base64('YourOrgName:YourAPIKEY');

You can get the base64 value of your string here:

https://www.base64encode.org/

For example, for my-org-name:123key4api it should be bXktb3JnLW5hbWU6MTIza2V5NGFwaQ==.

The complete header would look like:

Authorization: Basic bXktb3JnLW5hbWU6MTIza2V5NGFwaQ==

like image 154
MinusFour Avatar answered Oct 14 '22 23:10

MinusFour


Looks like you are facing trouble in getting the base64 value. Well you can make use of in-built function in Javscript as below.

Simply run below code in any JS runtime, (Simplest would be - open console tab in chrome developer tool)

"username:password!" // Here I used basic Auth string format  // Encode the plain string to base64 btoa("username:password!"); // output: "dXNlcm5hbWU6cGFzc3dvcmQh"   // Decode the base64 to plain string atob("dXNlcm5hbWU6cGFzc3dvcmQh"); // output: "username:password!" 
like image 34
Naveen Avatar answered Oct 14 '22 21:10

Naveen