Skip to content

Commit 6ef52d3

Browse files
committed
Fixed authentication issue
1 parent 3873018 commit 6ef52d3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/Github/HttpClient/Plugin/Authentication.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
5151
'client_secret' => $this->password,
5252
);
5353

54-
$query .= (false === strpos($query, '?') ? '?' : '&');
54+
$query .= empty($query) ? '' : '&';
5555
$query .= utf8_encode(http_build_query($parameters, '', '&'));
5656

5757
$uri = $uri->withQuery($query);
@@ -60,13 +60,14 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
6060

6161
case Client::AUTH_URL_TOKEN:
6262
$uri = $request->getUri();
63-
$existingQuery = $uri->getQuery();
64-
if (!empty($existingQuery)) {
65-
$existingQuery .= '&';
66-
}
67-
$newQuery = utf8_encode(http_build_query(array('access_token' => $this->tokenOrLogin), '', '&'));
63+
$query = $uri->getQuery();
64+
65+
$parameters = array('access_token' => $this->tokenOrLogin);
6866

69-
$uri = $uri->withQuery($existingQuery.$newQuery);
67+
$query .= empty($query) ? '' : '&';
68+
$query .= utf8_encode(http_build_query($parameters, '', '&'));
69+
70+
$uri = $uri->withQuery($query);
7071
$request = $request->withUri($uri);
7172
break;
7273

0 commit comments

Comments
 (0)