R.Karki
R.Karki

Reputation: 73

Print Headers value of Postman

I am trying to use rest api basic authentication and testing it through postman. On the authorization field, I used Type as Basic Auth and used the username and password in the field as in image below: enter image description here

Then it automatically generates the following on Header : enter image description here

So what I basically want is to print the value of Authorization i.e Basic YWRtaW46YWRtaW4= on my controller. Printing the username and password works fine with print_r($this->input->server('PHP_AUTH_USER')) and print_r($this->input->server('PHP_AUTH_PW')). However I didn't find a way to print the value from header field. Is there any best practice to achieve this. Any help appreciated. Thank You !

Upvotes: 0

Views: 2572

Answers (2)

Bhargesh shah
Bhargesh shah

Reputation: 11

just copy paste this code and you get your output in this format ==>

Basic YWRtaW46YWRtaW4=

$token = $this->input->get_request_header('Authorization');
print_r($token);
die;

Upvotes: 1

StewFeed
StewFeed

Reputation: 1

What I understand is you want to print the value from the header. There is a way to print it to the console or to the Test tab.

var (name) = postman.getResponseHeader("value-you-want-to-print");

// to console 
console.log((name));

// to Test
tests[(name)] = (name);

Upvotes: 0

Related Questions