Fixes to make SO login work. GitHub now works also (was a FF plugin bug)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php namespace SocialNorm\StackOverflow;
|
||||
|
||||
use SocialNorm\Exceptions\AuthNotUsableException;
|
||||
use SocialNorm\Exceptions\InvalidAuthorizationCodeException;
|
||||
use SocialNorm\Providers\OAuth2Provider;
|
||||
use GuzzleHttp\Client as HttpClient;
|
||||
use SocialNorm\Request;
|
||||
@@ -21,6 +23,7 @@ class StackOverflowProvider extends OAuth2Provider
|
||||
protected $headers = [
|
||||
'authorize' => [],
|
||||
'access_token' => [
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/x-www-form-urlencoded'
|
||||
],
|
||||
'user_details' => [],
|
||||
@@ -65,12 +68,21 @@ class StackOverflowProvider extends OAuth2Provider
|
||||
|
||||
protected function parseTokenResponse($response)
|
||||
{
|
||||
return $this->parseJsonTokenResponse($response);
|
||||
return explode('=', $response, 2)[1];
|
||||
}
|
||||
|
||||
protected function parseUserDataResponse($response)
|
||||
{
|
||||
return json_decode($response, true);
|
||||
$decoded = (array)json_decode($response, true);
|
||||
|
||||
if ($decoded === false || json_last_error())
|
||||
throw new InvalidAuthorizationCodeException('Corrupt response json: ' . $response . ", error " . json_last_error_msg());
|
||||
|
||||
if (0 == count(array_get($decoded, 'items'))) {
|
||||
throw new AuthNotUsableException('No profile on StackOverflow. Resp: '.$response);
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
protected function userId()
|
||||
|
||||
Reference in New Issue
Block a user