-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBitbucket.php
50 lines (41 loc) · 1.51 KB
/
Bitbucket.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Class Bitbucket
*
* @created 29.07.2019
* @author smiley <smiley@chillerlan.net>
* @copyright 2019 smiley
* @license MIT
*/
declare(strict_types=1);
namespace chillerlan\OAuth\Providers;
use chillerlan\OAuth\Core\{
AuthenticatedUser, ClientCredentials, ClientCredentialsTrait, CSRFToken, OAuth2Provider, TokenRefresh, UserInfo,
};
/**
* Bitbucket OAuth2 (Atlassian)
*
* @link https://developer.atlassian.com/cloud/bitbucket/oauth-2/
*/
class Bitbucket extends OAuth2Provider implements ClientCredentials, CSRFToken, TokenRefresh, UserInfo{
use ClientCredentialsTrait;
public const IDENTIFIER = 'BITBUCKET';
protected string $authorizationURL = 'https://bitbucket.org/site/oauth2/authorize';
protected string $accessTokenURL = 'https://bitbucket.org/site/oauth2/access_token';
protected string $apiURL = 'https://api.bitbucket.org/2.0';
protected string|null $apiDocs = 'https://developer.atlassian.com/bitbucket/api/2/reference/';
protected string|null $applicationURL = 'https://developer.atlassian.com/apps/';
/** @codeCoverageIgnore */
public function me():AuthenticatedUser{
$json = $this->getMeResponseData('/user');
$userdata = [
'data' => $json,
'avatar' => $json['links']['avatar']['href'],
'displayName' => $json['display_name'],
'handle' => $json['username'],
'id' => $json['account_id'],
'url' => $json['links']['self']['href'],
];
return new AuthenticatedUser($userdata);
}
}