tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.3k stars 1.54k forks source link

Request headers empty in vendor/tymon/jwt-auth/src/Http/Parser/Parser.php #1241

Open jesperbjerke opened 7 years ago

jesperbjerke commented 7 years ago

Trying to use the parseToken() in a controller method but it keeps saying it couldn't retrieve the token from the request. Digging into that, the request in my controller method has headers:

public function refresh(Request $request)
{
        echo '<pre>';
            var_dump($request->header());
        echo '<pre>';
        die();
}

produces

/app/Http/Controllers/AuthController.php:118:
array (size=12)
  'accept-language' => 
    array (size=1)
      0 => string 'en-US,en;q=0.8' (length=14)
  'accept-encoding' => 
    array (size=1)
      0 => string 'gzip, deflate' (length=13)
  'accept' => 
    array (size=1)
      0 => string '*/*' (length=3)
  'content-type' => 
    array (size=1)
      0 => string 'text/plain;charset=UTF-8' (length=24)
  'user-agent' => 
    array (size=1)
      0 => string 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36' (length=115)
  'origin' => 
    array (size=1)
      0 => string 'chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop' (length=51)
  'cache-control' => 
    array (size=1)
      0 => string 'no-cache' (length=8)
  'postman-token' => 
    array (size=1)
      0 => string 'XXXXXX' (length=36)
  'authorization' => 
    array (size=1)
      0 => string 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vYXBpLnRpbmdyLmFwcC9hdXRoL2xvZ2luIiwiaWF0IjoxNDk5MTg3NjIwLCJleHAiOjE0OTkxODc2ODAsIm5iZiI6MTQ5OTE4NzYyMCwianRpIjoiSE5oa0lHbFg4R1ZWVndRcyIsInN1YiI6MTJ9.E3snWGvCc7I-iuf8udg9sLpgiqruBLbqJpoG7ATn83' (length=255)
  'content-length' => 
    array (size=1)
      0 => string '305' (length=3)
  'connection' => 
    array (size=1)
      0 => string 'keep-alive' (length=10)
  'host' => 
    array (size=1)
      0 => string 'XXXXXXXXXXXXX' (length=13)

But in vendor/tymon/jwt-auth/src/Http/Parser/Parser.php

public function parseToken()
    {
        echo '<pre>';
            var_dump($this->request->header());
        echo '<pre>';
        die();
        foreach ($this->chain as $parser) {
            $response = $parser->parse($this->request);

            if ($response !== null) {
                return $response;
            }
        }
    }

produces

/vendor/tymon/jwt-auth/src/Http/Parser/Parser.php:85:
array (size=0)
  empty

Any idea what's wrong? I'm running this in Lumen 5.4 with Homestead and Nginx

tymondesigns commented 7 years ago

closed by #1243