vendredi 31 mars 2017

Get authorization Form Lumen ( Laravel micro framework) header From Laravel

In project , all API's call from Lumen. Front is developed in Laravel. We are calling Lumen APIs using Guzzle http client guzzleHttp .

Now, I need to set header Authorization for all API calling so I'm sending token in header from laravel but in Lumen I can't get token in Lumen request header.

below is the example code. :

Laravel Controller Code

public function get_category(){


    $accessToken = 'kjdhfdkjfhdkjfhfjkdf9875443213456';


    $response = \Guzzle::request("GET","example.com", "categories",['headers' => [
        'Authorization' => $accessToken
    ]]);

    $category_all = json_decode($response->getBody()->getContents(),true);

    return $category_all;

}

Lumen Middleware Code. :

 public function handle($request, Closure $next)
{

   dd($request);

}

In Lumen request I can't get token in request header.

any help will be thankful.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire