Answer the question
In order to leave comments, you need to log in
POST request to github returns 500 error, what's the problem?
Hello!
I request data to update the token from Github like this:
$data = $guzzleClient->post(
'https://github.com/login/oauth/access_token',
[
'form_params' => [
'refresh_token' => $user->github_refresh_token,
'grant_type' => 'refresh_token',
'client_id' => config('services.github.client_id'),
'client_secret' => config('services.github.client_secret'),
]
]
);
Server error: `POST https://github.com/login/oauth/access_token` resulted in a `500 Internal Server Error`
Answer the question
In order to leave comments, you need to log in
It ended up being solved like this:
$guzzleClient = new \GuzzleHttp\Client([
'headers' => [
'Content-Type' => 'application/json'
]
]);
$data = $guzzleClient->post(
'https://github.com/login/oauth/access_token',
[
'json' => [
'refresh_token' => $user->github_refresh_token,
'grant_type' => 'refresh_token',
'client_id' => config('services.github.client_id'),
'client_secret' => config('services.github.client_secret'),
],
'http_errors' => false
]
);
Guzzle has the ability to throw exceptions in case of errors - https://docs.guzzlephp.org/en/stable/quickstart.ht... - some types of exceptions have the ability to look at the server response. Wangyu that github in the answer writes in more detail what is wrong with your request.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question