【发布时间】:2019-10-16 19:19:41
【问题描述】:
我想从 mailchimp oauth2 获取访问令牌,但每次尝试都失败了。在这里我使用了 guzzle,我的实际要求是
卷曲--请求发布\ --url 'https://login.mailchimp.com/oauth2/token' \ --data "grant_type=authorization_code&client_id={client_id}&client_secret={client_secret}&redirect_uri={encoded_url}&code={code}" \ --包括
我已经尝试过 curl 和 javascript,但 mailchimp 不接受 javascript 请求 这是我使用的代码:
$http = new Client(['base_uri' => 'https://login.mailchimp.com/oauth2',
'defaults' => [
'exceptions' => false ],
'header' => [
'Accept' => 'application/json',
'Content-Type' => 'application/x-www-form-urlencoded'
],
'verify' => false
]);
$result = $http->request('POST','/token', [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'redirect_uri' => $this->redirect_uri,
'code' => $code,
],
]);
$response = $result->send();
$responseBody = $response->getBody(true);
var_dump($responseBody);
die();
预期的实际结果是:
"access_token":"5c6ccc561059aa386da9d112215bae55","expires_in":0,"scope":null
但我的错误客户端错误:
POST https://login.mailchimp.com/token 导致 404 Not Found 响应:
【问题讨论】:
标签: laravel api oauth-2.0 mailchimp guzzle