When using the explicit oath authentication for stack apps, I have problem recieving the access_token. A user goes to /approve and is then forwarded to approve the app. When redirected back to my site I catch the code parameter and do the final POST to get the access_token. However I cant find it in the response object!
This is my php routes file:
use GuzzleHttp\Client;
Route::get('/approve', function () {
header('Location: https://stackexchange.com/oauth?client_id=12345&scope=write_access&redirect_uri=https://mysite.com/approved');
});
Route::get('/approved', function (Request $request) {
$client = new Client();
$response = $client->request('POST', 'https://stackexchange.com/oauth/access_token/json', [
'form_params' => [
'client_id' => 12345,
'client_secret' => 'apfeusenfpuansefpunapfn((',
'code' => \Request::get("code"),
'redirect_uri' => 'https://mysite.com/approved'
]
]);
dd($response); // dumping the response gives no trace of access_token
});
- Running getStatusCode() on the response object gives a 200 All ok.
- Dumping the full response, body, or headers give me no reference of the access_token whatsoever.
- I tried swapping "form_params" to "query" same result.
- Adding "json" to api url no change.
- Im using Guzzle 6
Any ideas, where did I go wrong?