i want to get access token from mailchimp oauth2 but in every try i was fail. Here i used guzzle and my actual request is
curl --request POST \ --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}" \ --include
i already try curl and javascript but javascript request is not accepted by mailchimp this is code i used:
$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();
the expected actual result is:
"access_token":"5c6ccc561059aa386da9d112215bae55","expires_in":0,"scope":null
but my error Client error:
POST https://login.mailchimp.com/token
resulted in a 404 Not Found
response: