我无法让laravel应用程序访问同一服务器的另一个laravel应用程序中的api端点。我可以在终端和邮递员中使用它,但不能从laravel应用程序本身中使用它,它们都可以获取身份验证令牌并在p; ostman和终端中使用工作,但不能在laravel中使用。 (杀死我这是在前一天工作)
我在Win 10上使用WAMP尝试了许多Guzzle和curl配置。Laravel Framework版本5.3.31,PHP 7.2.18
try {
$response = $http->request('POST',$this->base_oauth_url. 'oauth/token', [
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/x-www-form-urlencoded',
],
'form_params' => [
'grant_type' => 'password',
'client_id' => self::API_CLIENT_ID,
'client_secret' => self::API_SECRET,
'username' => self::API_USERNAME,
'password' => self::API_PASSWORD,
'scope' => '*',
],
'debug'=>$this->debug,
'allow_redirects' => false,
'verify' => false,
]);
} catch (ClientException $e) {
throw new Exception("Guzzle Error: {$e->getMessage()}");
} catch (Exception $e) {
throw new Exception("Send Error: ({$e->getCode()}): {$e->getMessage()}");
}
$response = json_decode((string) $response->getBody()->getContents());
$data = array();
$data['access_token'] = $response->access_token;
$data['refresh_token'] = $response->refresh_token;
错误:
大量错误:客户端错误:POST http://mytestdomain.com/oauth/token
导致了401 Unauthorized
的响应:
{“错误”:“ invalid_client”,“消息”:“客户端身份验证失败”}