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