Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel get request headers

I am using POSTMAN to send a GET request into the api with a header containing Authorization.

I know the data header works because if it doesn't the route returns a 401 error.

I wanted to get the Authorization header like so:

$access_token = Request::header('Authorization'); 

But noticed that it returns NULL.

So I tried to catch the values with:

die(var_dump(Request::header())); 

And noticed that it doesn't contain any Authorization header. Just host to cookie headers.


update

Should get Authorization: Bearer ACCESS TOKEN

like image 702
majidarif Avatar asked Dec 31 '13 07:12

majidarif


People also ask

How can you retrieve the full URL for the incoming request Laravel?

The “path” method is used to retrieve the requested URI. The is method is used to retrieve the requested URI which matches the particular pattern specified in the argument of the method. To get the full URL, we can use the url method.

How do I get params in Laravel?

Method 1: $request->route('parameter_name') We can access route parameters in two ways. One way is by using $request->route('parameter_name') ., where parameter_name refers to what we called the parameter in the route.


1 Answers

What POSTMAN Version did you use?

Are you on your local machine or managed server, some hosting companies don't allow AUTHORIZATION HEADER.

.htaccess modification

 RewriteEngine On  RewriteCond %{HTTP:Authorization} .  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
like image 164
dschniepp Avatar answered Sep 22 '22 08:09

dschniepp