X-Git-Url: https://git.cweiske.de/shpub.git/blobdiff_plain/f60fce4bd4a0cba54b686f64bc5a83eb580356f4..f0dde6f405cb0564e409d9cf2aaa38ef731f3dea:/src/shpub/Command/Connect.php?ds=sidebyside diff --git a/src/shpub/Command/Connect.php b/src/shpub/Command/Connect.php index c855e66..b39665b 100644 --- a/src/shpub/Command/Connect.php +++ b/src/shpub/Command/Connect.php @@ -158,9 +158,9 @@ class Command_Connect 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'); @@ -177,11 +177,13 @@ class Command_Connect 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'; } @@ -277,7 +279,6 @@ class Command_Connect parse_str($parts['query'], $query); if (isset($query['code']) && isset($query['state']) - && isset($query['me']) ) { fwrite($sock, $responseOk); fclose($sock);