I have 2 sites on local both in Laravel, I am trying to call passport based rest API from project 1 to 2. But it showing Unauthenticated response but it's working perfectly on postman.
Curl code which i am using on controller: $curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_HEADER => 1,
CURLINFO_HEADER_OUT => true,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_URL => "http://localhost/payment/api/payrequest",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data1),
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImJiZDEzMzlmZjYyNGM2MWQxZjRiMDFlNmEwODA1ZDdmYTY0YzBhOGM4OGY2MjhlOWNiMzU1N2U3MWI1N2RkNDMyYjM5MDE5ZDI3NTU0ZmQyIn0.eyJhdWQiOiIxIiwianRpIjoiYmJkMTMzOWZmNjI0YzYxZDFmNGIwMWU2YTA4MDVkN2ZhNjRjMGE4Yzg4ZjYyOGU5Y2IzNTU3ZTcxYjU3ZGQ0MzJiMzkwMTlkMjc1NTRmZDIiLCJpYXQiOjE1NDM4MjE3NDIsIm5iZiI6MTU0MzgyMTc0MiwiZXhwIjoxNTc1MzU3NzQyLCJzdWIiOiIyIiwic2NvcGVzIjpbXX0.FHkGFHJGMXH6QAInbAxSkqz7rmSZwfr0yd9mFFBtVpCUe5m1Xrw7h3EMlZ8JqHqmYwcosofjwSMuSn5ihQax726qgz7QExYaisZ0KQKNlHOtTTyk2gsybs0_ZI63UTk_-0NO_uiGTdZkWQn_fvYSpCIq-kRZohJ2RoXzd5iCv0oYBUKuGlnXlunuBgteDY0TyOAM4qvN18O2JBHjiVxGMNmkah3Gq_REUxAY93SYucGu_4fAgtjCVNfdhtmjNSE4eflPr7RZ5ip-nQFfZBjDEQZUY8DqQNW7k6LZZiJfWd8685IByMOKric5EUBpUJ1zAyMbsKrbeCuvnfKPWhiULgdPYe7riML78ek4e-Ec1RYpmKva9zw6aP1s85W1WwZzWVQp4B-9aM0D81g172pjl9Op5EsvqgLwo3ZFWFUTGZ14rp9KQ5ZbLJRiwiVCstlxpFECY8H5UjVXOXnQSGMgx_5TAlcc_CfQXkJGhhO_MtQwCA7tNCfz44DC4Wjf9Eji8Hc0hnTULMShMAMwLHl8bUCtfcr2iGGdw4jHmaEbmEkaNpK4MjIUiTFjjSiGZXvWxg5UjqRlvXl3AWAysh3ez0ea_aC_OiKWP-pkJbClPNK5inAY9JuioyTijaNM4urLlh0y0JOQmF4lNq8NhzRNuF81jIZ3xsyyrYxubMEi2oI",
'Content-Type: application/json',
'cache-control: no-cache',
'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW',
'postman-token: a3e3f245-b27d-bb1e-997e-8dae837ccb8d'
),
));
$response = curl_exec($curl);
echo "<pre>";
print_r(curl_getinfo($curl));
echo "</pre>";
$err = curl_error($curl);
curl_close($curl);
if ($err) {
dd($err);
} else {
dd($response);
}
can not determine what is the exact issue and also add .htaccess authorization code.
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Also if i try using without auth it working fine but with Route::group(['middleware' => 'auth:api'], function() {
} its not wotking.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire