Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit 4c63867

Browse files
committed
Update GitHub authorization to use token in header instead of query
1 parent 8ab07b3 commit 4c63867

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ public function request($path, $method = 'GET', $body = null, array $extraHeader
167167
$uri->addToQuery('apikey', $token->getAccessToken());
168168
} elseif (static::AUTHORIZATION_METHOD_HEADER_BEARER === $this->getAuthorizationMethod()) {
169169
$extraHeaders = array_merge(array('Authorization' => 'Bearer ' . $token->getAccessToken()), $extraHeaders);
170+
} elseif (static::AUTHORIZATION_METHOD_HEADER_TOKEN === $this->getAuthorizationMethod()) {
171+
$extraHeaders = array_merge(array('Authorization' => 'token ' . $token->getAccessToken()), $extraHeaders);
170172
}
171173

172174
$extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders);

phpoauthlib/src/OAuth/OAuth2/Service/GitHub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function getAccessTokenEndpoint()
122122
*/
123123
protected function getAuthorizationMethod()
124124
{
125-
return static::AUTHORIZATION_METHOD_QUERY_STRING;
125+
return static::AUTHORIZATION_METHOD_HEADER_TOKEN;
126126
}
127127

128128
/**

phpoauthlib/src/OAuth/OAuth2/Service/ServiceInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface ServiceInterface extends BaseServiceInterface
2323
const AUTHORIZATION_METHOD_QUERY_STRING = 2;
2424
const AUTHORIZATION_METHOD_QUERY_STRING_V2 = 3;
2525
const AUTHORIZATION_METHOD_QUERY_STRING_V3 = 4;
26+
const AUTHORIZATION_METHOD_HEADER_TOKEN = 5;
2627

2728
/**
2829
* Retrieves and stores/returns the OAuth2 access token after a successful authorization.

0 commit comments

Comments
 (0)