Reputation: 73
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:
Then it automatically generates the following on Header :
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
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
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