Skip to content

Commit 7fa4ceb

Browse files
Lee NugentLee Nugent
Lee Nugent
authored and
Lee Nugent
committed
Added the ability to authenticate using an OAuth token
1 parent f3c9f70 commit 7fa4ceb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/Gitlab/Client.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class Client
4444
*/
4545
const AUTH_HTTP_TOKEN = 'http_token';
4646

47+
/**
48+
* Constant for authentication method. Indicates the OAuth method with a key
49+
* obtain using Gitlab's OAuth provider.
50+
*/
51+
const AUTH_OAUTH_TOKEN = 'oauth_token';
52+
4753
/**
4854
* @var array
4955
*/

lib/Gitlab/HttpClient/Listener/AuthListener.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ public function preSend(RequestInterface $request)
7676

7777
$request->fromUrl(new Url($url));
7878
break;
79+
80+
case Client::AUTH_OAUTH_TOKEN:
81+
$request->addHeader('Authorization: Bearer '.$this->token);
82+
if (!is_null($this->sudo)) {
83+
$request->addHeader('SUDO: '.$this->sudo);
84+
}
85+
break;
7986
}
8087
}
8188

0 commit comments

Comments
 (0)