【发布时间】:2023-03-27 21:40:01
【问题描述】:
我创建了一个带有护照的 api,并希望使用密码授予令牌,因为它更多的是应用程序与应用程序的交互。但是当我尝试访问它时出现以下错误。
GuzzleHttp\Exception\ClientException
Client error: `POST http://127.0.0.1:8000/oauth/token` resulted in a `401 Unauthorized` response: {"error":"invalid_client","error_description":"Client authentication failed","message":"Client authentication failed"}
我的路线
Route::get('/get_token_by_password', function (Request $request) {
$http = new GuzzleHttp\Client;
$response = $http->post('http://192.168.0.103:8000/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => 13,
'client_secret' => 'f37AwQGsVMiZDVu786KiRdbpn4MXYSBWCvqNcqiC',
'username' => 'developer@ymail.com',
'password' => '123456789',
'scope' => '*',
],
]);
return json_decode((string) $response->getBody(), true);
})->name('get_token_by_password');
我可能做错了什么?
另外,如何使用邮递员获取令牌?
- 我如何获得一个链接,以便在其他想要使用我的 api 的应用程序中使用
【问题讨论】:
标签: laravel api oauth laravel-passport laravel-api