我正在向POST api.myserver.com/v1/oauth/token发送请求,以获取带有client_credentials的令牌,如下所示:
$client = new GuzzleHttp\Client; // A guzzle client
$response = $this->client->post('http://api.myserver.com/v1/oauth/token', [
'form_params' => [
'grant_type' => 'client_credentials',
'client_id' => 'MY_CLIENT_ID',
'client_secret' => 'MY_CLIENT_SECRET',
'scope' => ''
],
'headers' => [
'Accept' => 'application/json'
]
));我使用的是apiato框架,因此默认的laravel passport令牌生成路由已修改为类似api.myserver.com/v1/oauth/token的内容,因此路径也已修改。
现在,当我从浏览器运行上面的代码时,它抛出了一个404 not found exception。当我在POSTman上运行它时,它工作得很好。而且,当我在测试环境中运行它时,它也运行得很好。
Client error: `POST http://api.myserver.com/v1/oauth/token` resulted in a `404 Not Found` response:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" co (truncated...)我尝试更改到http://myserver.com/oauth/token的路径,但没有成功。会出什么问题呢?
发布于 2020-05-27 15:09:46
这种情况发生在我身上,尤其是client_credentials grant_type。如果我使用authorization_code,它可以工作。还不知道为什么。
发布于 2019-01-12 16:31:05
那么,当您尝试使用浏览器访问此端点时得到404的原因是因为它是一个POST请求。当您通过浏览器访问URL时,它是一个GET请求。
https://stackoverflow.com/questions/54157683
复制相似问题