Support auth servers with ? in their URL
authorChristian Weiske <cweiske@cweiske.de>
Sat, 28 Oct 2017 13:08:10 +0000 (15:08 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Sat, 28 Oct 2017 13:08:10 +0000 (15:08 +0200)
Resolves: https://github.com/cweiske/shpub/issues/10

src/shpub/Command/Connect.php

index e920777..6ac5ed4 100644 (file)
@@ -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';
     }