Log::err($res->getBody());
exit(2);
}
- if ($res->getHeader('content-type') == 'application/x-www-form-urlencoded') {
+ if (Util::getMimeType($res) == 'application/x-www-form-urlencoded') {
parse_str($res->getBody(), $tokenParams);
- } elseif ($res->getHeader('content-type') == 'application/json') {
+ } elseif (Util::getMimeType($res) == 'application/json') {
$tokenParams = json_decode($res->getBody(), true);
} else {
Log::err('Wrong content type in auth verification response');
protected function getBrowserAuthUrl($host, $user, $redirect_uri, $state, $scope)
{
+ $sep = strpos($host->endpoints->authorization, '?') === false
+ ? '?' : '&';
return $host->endpoints->authorization
- . '?me=' . urlencode($user)
+ . $sep . 'me=' . urlencode($user)
. '&client_id=' . urlencode(static::$client_id)
. '&redirect_uri=' . urlencode($redirect_uri)
- . '&state=' . $state
+ . '&state=' . urlencode($state)
. '&scope=' . urlencode($scope)
. '&response_type=code';
}