Skip to content

Added the ability to authenticate using an OAuth token #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/Gitlab/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class Client
*/
const AUTH_HTTP_TOKEN = 'http_token';

/**
* Constant for authentication method. Indicates the OAuth method with a key
* obtain using Gitlab's OAuth provider.
*/
const AUTH_OAUTH_TOKEN = 'oauth_token';

/**
* @var array
*/
Expand Down
7 changes: 7 additions & 0 deletions lib/Gitlab/HttpClient/Listener/AuthListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public function preSend(RequestInterface $request)

$request->fromUrl(new Url($url));
break;

case Client::AUTH_OAUTH_TOKEN:
$request->addHeader('Authorization: Bearer '.$this->token);
if (!is_null($this->sudo)) {
$request->addHeader('SUDO: '.$this->sudo);
}
break;
}
}

Expand Down