我使用 Laravel 7 和 Passport 但出现一些错误
这是我的 Controller
class LoginController extends Controller
{
public function login(Request $request)
{
$response = Http::post(
'http://localhost/vue-spa/public/oauth/token',
[
'grant_type' => 'password',
'client_id' => 2,
'client_secret' => 'Z7YFRiUQITRGkWAgCuI8rNyss7BVQJDQXMZrRWiR',
'username' => $request->email,
'password' => $request->password,
'scope' => '',
]
);
if ($response->clientError()) {
return $response->json('Email atau Password Salah', 400);
} elseif ($response->serverError()) {
return $response->json('Server Error', 500);
}
return $response->body();
}
}
我得到这样的错误
我必须解决这个问题
直接替换即可
'grant_type' => 'password'
至
'grant_type' => 'client_credentials'
最佳答案
我必须解决这个问题
直接替换即可
'grant_type' => 'password'
至
'grant_type' => 'client_credentials'
关于laravel - "error": "invalid_grant" Laravel 7 Passport,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62000112/