The objective is to exchange the authorization code for the access and refresh token.
Error:
GuzzleHttp\Exception\ClientException #400
Client error response
[url] http://sandbox.feedly.com/v3/auth/token?code=[auth_code]&client_id=sandbox&client_secret=[secret]&redirect_uri=https%253A%252F%252F[site url]&grant_type=authorization_code&state=%23
[status code] 400
[reason phrase] Bad Request
Related code:
$client = new GuzzleHttp\Client();
$parameters = ['code'=>$_GET['code'],'client_id'=>'sandbox','client_secret'=> '[secret]','redirect_uri'=>urlencode('https://[site url]'),'grant_type'=>'authorization_code', 'state'=>'#'];
$params = http_build_query($parameters);
$request = $client->createRequest('POST', 'http://sandbox.feedly.com/v3/auth/token?'.$params);
$request->addHeader('Accept-Encoding','GZIP');
$request->setHeader('Authorization', "auth-code");
$request->addHeader('Content-Type','application/json');
$response = $client->send($request);
var_dump($response->json());
Also tried with state = "state.passed.in"
but throws same error.
Can you point out the error in the code snippet. It's using the Feedly API v3 sandbox and the Guzzle HTTP client.
If following the request URL, it throws "get not allowed".
Updated code snippet:
$client = new GuzzleHttp\Client();
$parameters = ['code'=>$_GET['code'],'client_id'=>'sandbox','client_secret'=> '[secret]','redirect_uri'=>urlencode('https://[site url]'),'grant_type'=>'authorization_code', 'state'=>'#'];
$params = http_build_query($parameters);
$request = $client->createRequest('POST', 'http://sandbox.feedly.com/v3/auth/token?'.$params);
$response = $client->send($request);
var_dump($response->json());
Error on updated code:
GuzzleHttp\Exception\ServerException #522
Server error response [url] http://sandbox.feedly.com/v3/auth/token?code=[auth_code]&client_id=sandbox&client_secret=[secret]&redirect_uri=https%253A%252F%252F[site url]&grant_type=authorization_code&state=%23
[status code] 522
[reason phrase] Origin Connection Time-out
Note: The update code is throwing the same error (after couple of hours) that is
GuzzleHttp\Exception\ClientException #400
Client error response
[url] http://sandbox.feedly.com/v3/auth/token?code=[auth_code]&client_id=sandbox&client_secret=[secret]&redirect_uri=https%253A%252F%252F[site url]&grant_type=authorization_code&state=%23
[status code] 400
[reason phrase] Bad Request