3 final class PhutilBitbucketAuthAdapter
extends PhutilOAuth1AuthAdapter
{
7 public function getAccountID() {
8 return idx($this->getUserInfo(), 'username');
11 public function getAccountName() {
12 return idx($this->getUserInfo(), 'display_name');
15 public function getAccountURI() {
16 $name = $this->getAccountID();
18 return 'https://bitbucket.org/'.$name;
23 public function getAccountImageURI() {
24 return idx($this->getUserInfo(), 'avatar');
27 public function getAccountRealName() {
29 idx($this->getUserInfo(), 'first_name'),
30 idx($this->getUserInfo(), 'last_name'),
32 $parts = array_filter($parts);
33 return implode(' ', $parts);
36 public function getAdapterType() {
40 public function getAdapterDomain() {
41 return 'bitbucket.org';
44 protected function getRequestTokenURI() {
45 return 'https://bitbucket.org/api/1.0/oauth/request_token';
48 protected function getAuthorizeTokenURI() {
49 return 'https://bitbucket.org/api/1.0/oauth/authenticate';
52 protected function getValidateTokenURI() {
53 return 'https://bitbucket.org/api/1.0/oauth/access_token';
56 private function getUserInfo() {
57 if ($this->userInfo
=== null) {
58 // We don't need any of the data in the handshake, but do need to
59 // finish the process. This makes sure we've completed the handshake.
60 $this->getHandshakeData();
62 $uri = new PhutilURI('https://bitbucket.org/api/1.0/user');
64 $data = $this->newOAuth1Future($uri)
68 $this->userInfo
= idx($data, 'user', array());
70 return $this->userInfo
;