Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
测试API Jetstream Sanctum Laravel 8x的标题存在问题,并获得许可_Laravel_Api_Header_Laravel Sanctum - Fatal编程技术网

测试API Jetstream Sanctum Laravel 8x的标题存在问题,并获得许可

测试API Jetstream Sanctum Laravel 8x的标题存在问题,并获得许可,laravel,api,header,laravel-sanctum,Laravel,Api,Header,Laravel Sanctum,我生成了两个令牌: tokenA = As2 ... xxxxx //can perform ONLY create tokenB = Bs2 ... xxxxx //can perform ONLY update 我有以下问题 $response = $this->withHeaders([ 'Accept' => 'application/json', 'Authorization' => 'Bearer '.$token

我生成了两个令牌:

tokenA = As2 ... xxxxx //can perform ONLY  create
tokenB = Bs2 ... xxxxx //can perform ONLY update
我有以下问题

$response = $this->withHeaders([
            'Accept' => 'application/json',
            'Authorization' => 'Bearer '.$tokenA],
        ])->post('/api/store',$data);
        $response->assertStatus(201);

//the store is made without problems

$response = $this->withHeaders([
            'Accept' => 'application/json',
            'Authorization' => 'Bearer '.tokenB,
        ])->put('/api/update',$dataUpdate);
        $respone->assertStatus(200);

//the test fails and returns 403. As if you don't have permission to do that
如果我只打电话

$response = $this->withHeaders([
            'Accept' => 'application/json',
            'Authorization' => 'Bearer '.tokenB,
        ])->put('/api/update',$dataUpdate);
        $response->assertStatus(200);
执行更新时没有问题

如何依次运行存储和更新

$response似乎继续持有tokenA的值