发送JWT授权guzzle

时间:2017-06-29 17:18:48

标签: symfony jwt guzzle

我试图测试这个jwt授权它可以很好地从控制台进行卷曲但是当我尝试使用guzzle它给我一个空的响应任何帮助非常感谢

        $client = new Client([
        'base_uri' => 'http://localhost',
        'timeout' => 2.0,
    ]);

  $res =   $client->request('GET', '/api/private', [
    'headers' => [
        'Content-Type' => 'application/json',
        'Authorization'     => 'Bearer JWTTOKENHERE'
        ]
    ]);

我也遇到了这条路线/ api / login_check的问题,从php服务器上运行正常,但apache返回404

curl -X POST http://localhos/api/login_check -d _username=johndoe -d _password=test

但有了guzzle,我使用LexikJWTAuthenticationBundle

找不到404
      $credentials = base64_encode('test@email.com:test');
      $res = $this->client->request('POST','/api/login_check',
          [
              'headers' => [
                  'Authorization' => ['Basic ' . $credentials]
              ]
          ]);
      dump($res);die();

0 个答案:

没有答案