Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 10e5db0

Browse files
committed
🛀
1 parent a022756 commit 10e5db0

40 files changed

+365
-375
lines changed

src/Amazon.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ class Amazon extends OAuth2Provider implements CSRFToken, TokenRefresh{
2929
public const SCOPE_PROFILE_USER_ID = 'profile:user_id';
3030
public const SCOPE_POSTAL_CODE = 'postal_code';
3131

32-
protected string $authURL = 'https://www.amazon.com/ap/oa';
33-
protected string $accessTokenURL = 'https://www.amazon.com/ap/oatoken';
34-
protected string $apiURL = 'https://api.amazon.com';
35-
protected ?string $apiDocs = 'https://login.amazon.com/';
36-
protected ?string $applicationURL = 'https://sellercentral.amazon.com/hz/home';
37-
38-
protected array $defaultScopes = [
32+
protected array $defaultScopes = [
3933
self::SCOPE_PROFILE,
4034
self::SCOPE_PROFILE_USER_ID,
4135
];
4236

37+
protected string $authURL = 'https://www.amazon.com/ap/oa';
38+
protected string $accessTokenURL = 'https://www.amazon.com/ap/oatoken';
39+
protected string $apiURL = 'https://api.amazon.com';
40+
protected string|null $apiDocs = 'https://login.amazon.com/';
41+
protected string|null $applicationURL = 'https://sellercentral.amazon.com/hz/home';
42+
4343
/**
4444
* @inheritDoc
4545
*/

src/AzureActiveDirectory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ abstract class AzureActiveDirectory extends OAuth2Provider implements CSRFToken{
2222
public const SCOPE_OPENID_PROFILE = 'profile';
2323
public const SCOPE_OFFLINE_ACCESS = 'offline_access';
2424

25-
protected string $authURL = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize';
26-
protected string $accessTokenURL = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
27-
protected ?string $userRevokeURL = 'https://account.live.com/consent/Manage';
28-
protected ?string $applicationURL = 'https://aad.portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps';
25+
protected string $authURL = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize';
26+
protected string $accessTokenURL = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
27+
protected string|null $userRevokeURL = 'https://account.live.com/consent/Manage';
28+
protected string|null $applicationURL = 'https://aad.portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps';
2929

3030
}

src/BattleNet.php

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212

1313
use chillerlan\HTTP\Utils\MessageUtil;
1414
use chillerlan\OAuth\Core\{ClientCredentials, CSRFToken, OAuth2Provider, ProviderException};
15-
use chillerlan\OAuth\OAuthOptions;
16-
use chillerlan\Settings\SettingsContainerInterface;
17-
use Psr\Http\Client\ClientInterface;
1815
use Psr\Http\Message\ResponseInterface;
19-
use Psr\Log\LoggerInterface;
2016
use Throwable;
2117
use function in_array, sprintf, strtolower;
2218

@@ -32,34 +28,25 @@ class BattleNet extends OAuth2Provider implements ClientCredentials, CSRFToken{
3228
public const SCOPE_PROFILE_SC2 = 'sc2.profile';
3329
public const SCOPE_PROFILE_WOW = 'wow.profile';
3430

35-
protected array $defaultScopes = [
31+
protected array $defaultScopes = [
3632
self::SCOPE_OPENID,
3733
self::SCOPE_PROFILE_D3,
3834
self::SCOPE_PROFILE_SC2,
3935
self::SCOPE_PROFILE_WOW,
4036
];
4137

42-
protected ?string $apiDocs = 'https://develop.battle.net/documentation';
43-
protected ?string $applicationURL = 'https://develop.battle.net/access/clients';
44-
protected ?string $userRevokeURL = 'https://account.blizzard.com/connections';
38+
protected string|null $apiDocs = 'https://develop.battle.net/documentation';
39+
protected string|null $applicationURL = 'https://develop.battle.net/access/clients';
40+
protected string|null $userRevokeURL = 'https://account.blizzard.com/connections';
4541

4642
// the URL for the "OAuth" endpoints
4743
// @see https://develop.battle.net/documentation/battle-net/oauth-apis
48-
protected string $battleNetOauth;
49-
protected string $region;
50-
51-
/**
52-
* @inheritDoc
53-
*/
54-
public function __construct(
55-
ClientInterface $http,
56-
OAuthOptions|SettingsContainerInterface $options,
57-
LoggerInterface $logger = null
58-
){
59-
parent::__construct($http, $options, $logger);
60-
61-
$this->setRegion('eu');
62-
}
44+
protected string $battleNetOauth = 'https://oauth.battle.net';
45+
protected string $region = 'eu';
46+
// these URLs will be set dynamically, depending on the chose datacenter
47+
protected string $apiURL = 'https://eu.api.blizzard.com';
48+
protected string $authURL = 'https://oauth.battle.net/authorize';
49+
protected string $accessTokenURL = 'https://oauth.battle.net/token';
6350

6451
/**
6552
* Set the datacenter URLs for the given region

src/BigCartel.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
*/
2525
class BigCartel extends OAuth2Provider implements CSRFToken, TokenInvalidate{
2626

27-
protected string $authURL = 'https://my.bigcartel.com/oauth/authorize';
28-
protected string $accessTokenURL = 'https://api.bigcartel.com/oauth/token';
29-
protected string $revokeURL = 'https://api.bigcartel.com/oauth/deauthorize/%s'; // sprintf() user id!
30-
protected string $apiURL = 'https://api.bigcartel.com/v1';
31-
protected ?string $userRevokeURL = 'https://my.bigcartel.com/account';
32-
protected ?string $apiDocs = 'https://developers.bigcartel.com/api/v1';
33-
protected ?string $applicationURL = 'https://bigcartel.wufoo.com/forms/big-cartel-api-application/';
34-
protected array $apiHeaders = ['Accept' => 'application/vnd.api+json'];
27+
protected string $authURL = 'https://my.bigcartel.com/oauth/authorize';
28+
protected string $accessTokenURL = 'https://api.bigcartel.com/oauth/token';
29+
protected string $revokeURL = 'https://api.bigcartel.com/oauth/deauthorize/%s'; // sprintf() user id!
30+
protected string $apiURL = 'https://api.bigcartel.com/v1';
31+
protected string|null $userRevokeURL = 'https://my.bigcartel.com/account';
32+
protected string|null $apiDocs = 'https://developers.bigcartel.com/api/v1';
33+
protected string|null $applicationURL = 'https://bigcartel.wufoo.com/forms/big-cartel-api-application/';
34+
protected array $apiHeaders = ['Accept' => 'application/vnd.api+json'];
3535

3636
/**
3737
* @inheritDoc
@@ -56,7 +56,7 @@ public function me():ResponseInterface{
5656
/**
5757
* @inheritDoc
5858
*/
59-
public function invalidateAccessToken(AccessToken $token = null):bool{
59+
public function invalidateAccessToken(AccessToken|null $token = null):bool{
6060

6161
if($token === null && !$this->storage->hasAccessToken()){
6262
throw new ProviderException('no token given');

src/Bitbucket.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
*/
2121
class Bitbucket extends OAuth2Provider implements ClientCredentials, CSRFToken, TokenRefresh{
2222

23-
protected string $authURL = 'https://bitbucket.org/site/oauth2/authorize';
24-
protected string $accessTokenURL = 'https://bitbucket.org/site/oauth2/access_token';
25-
protected string $apiURL = 'https://api.bitbucket.org/2.0';
26-
protected ?string $apiDocs = 'https://developer.atlassian.com/bitbucket/api/2/reference/';
27-
protected ?string $applicationURL = 'https://developer.atlassian.com/apps/';
23+
protected string $authURL = 'https://bitbucket.org/site/oauth2/authorize';
24+
protected string $accessTokenURL = 'https://bitbucket.org/site/oauth2/access_token';
25+
protected string $apiURL = 'https://api.bitbucket.org/2.0';
26+
protected string|null $apiDocs = 'https://developer.atlassian.com/bitbucket/api/2/reference/';
27+
protected string|null $applicationURL = 'https://developer.atlassian.com/apps/';
2828

2929
/**
3030
* @inheritDoc

src/Deezer.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,34 @@
2424
*/
2525
class Deezer extends OAuth2Provider implements CSRFToken{
2626

27-
public const SCOPE_BASIC = 'basic_access';
28-
public const SCOPE_EMAIL = 'email';
29-
public const SCOPE_OFFLINE_ACCESS = 'offline_access';
30-
public const SCOPE_MANAGE_LIBRARY = 'manage_library';
31-
public const SCOPE_MANAGE_COMMUNITY = 'manage_community';
32-
public const SCOPE_DELETE_LIBRARY = 'delete_library';
33-
public const SCOPE_LISTENING_HISTORY = 'listening_history';
34-
35-
protected string $authURL = 'https://connect.deezer.com/oauth/auth.php';
36-
protected string $accessTokenURL = 'https://connect.deezer.com/oauth/access_token.php';
37-
protected string $apiURL = 'https://api.deezer.com';
38-
protected ?string $userRevokeURL = 'https://www.deezer.com/account/apps';
39-
protected ?string $apiDocs = 'https://developers.deezer.com/api';
40-
protected ?string $applicationURL = 'http://developers.deezer.com/myapps';
41-
protected int $authMethod = self::AUTH_METHOD_QUERY;
42-
43-
protected array $defaultScopes = [
27+
public const SCOPE_BASIC = 'basic_access';
28+
public const SCOPE_EMAIL = 'email';
29+
public const SCOPE_OFFLINE_ACCESS = 'offline_access';
30+
public const SCOPE_MANAGE_LIBRARY = 'manage_library';
31+
public const SCOPE_MANAGE_COMMUNITY = 'manage_community';
32+
public const SCOPE_DELETE_LIBRARY = 'delete_library';
33+
public const SCOPE_LISTENING_HISTORY = 'listening_history';
34+
35+
protected array $defaultScopes = [
4436
self::SCOPE_BASIC,
4537
self::SCOPE_EMAIL,
4638
self::SCOPE_OFFLINE_ACCESS,
4739
self::SCOPE_MANAGE_LIBRARY,
4840
self::SCOPE_LISTENING_HISTORY,
4941
];
5042

43+
protected string $authURL = 'https://connect.deezer.com/oauth/auth.php';
44+
protected string $accessTokenURL = 'https://connect.deezer.com/oauth/access_token.php';
45+
protected string $apiURL = 'https://api.deezer.com';
46+
protected string|null $userRevokeURL = 'https://www.deezer.com/account/apps';
47+
protected string|null $apiDocs = 'https://developers.deezer.com/api';
48+
protected string|null $applicationURL = 'http://developers.deezer.com/myapps';
49+
protected int $authMethod = self::AUTH_METHOD_QUERY;
50+
5151
/**
5252
* @inheritDoc
5353
*/
54-
public function getAuthURL(array $params = null, array $scopes = null):UriInterface{
54+
public function getAuthURL(array|null $params = null, array|null $scopes = null):UriInterface{
5555
$params ??= [];
5656

5757
if(isset($params['client_secret'])){
@@ -72,7 +72,7 @@ public function getAuthURL(array $params = null, array $scopes = null):UriInterf
7272
/**
7373
* @inheritDoc
7474
*/
75-
public function getAccessToken(string $code, string $state = null):AccessToken{
75+
public function getAccessToken(string $code, string|null $state = null):AccessToken{
7676
$this->checkState($state);
7777

7878
$body = [
@@ -112,7 +112,7 @@ protected function parseTokenResponse(ResponseInterface $response):AccessToken{
112112
$token = $this->createAccessToken();
113113

114114
$token->accessToken = $data['access_token'];
115-
$token->expires = ($data['expires'] ?? $data['expires_in'] ?? AccessToken::EOL_NEVER_EXPIRES);
115+
$token->expires = (int)($data['expires'] ?? $data['expires_in'] ?? AccessToken::EOL_NEVER_EXPIRES);
116116
$token->refreshToken = ($data['refresh_token'] ?? null);
117117

118118
unset($data['expires'], $data['expires_in'], $data['refresh_token'], $data['access_token']);

src/DeviantArt.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,31 @@
2323
*/
2424
class DeviantArt extends OAuth2Provider implements ClientCredentials, CSRFToken, TokenInvalidate, TokenRefresh{
2525

26-
public const SCOPE_BASIC = 'basic';
27-
public const SCOPE_BROWSE = 'browse';
28-
public const SCOPE_COLLECTION = 'collection';
29-
public const SCOPE_COMMENT_POST = 'comment.post';
30-
public const SCOPE_FEED = 'feed';
31-
public const SCOPE_GALLERY = 'gallery';
32-
public const SCOPE_MESSAGE = 'message';
33-
public const SCOPE_NOTE = 'note';
34-
public const SCOPE_STASH = 'stash';
35-
public const SCOPE_USER = 'user';
36-
public const SCOPE_USER_MANAGE = 'user.manage';
37-
38-
protected array $defaultScopes = [
26+
public const SCOPE_BASIC = 'basic';
27+
public const SCOPE_BROWSE = 'browse';
28+
public const SCOPE_COLLECTION = 'collection';
29+
public const SCOPE_COMMENT_POST = 'comment.post';
30+
public const SCOPE_FEED = 'feed';
31+
public const SCOPE_GALLERY = 'gallery';
32+
public const SCOPE_MESSAGE = 'message';
33+
public const SCOPE_NOTE = 'note';
34+
public const SCOPE_STASH = 'stash';
35+
public const SCOPE_USER = 'user';
36+
public const SCOPE_USER_MANAGE = 'user.manage';
37+
38+
protected array $defaultScopes = [
3939
self::SCOPE_BASIC,
4040
self::SCOPE_BROWSE,
4141
];
4242

43-
protected string $authURL = 'https://www.deviantart.com/oauth2/authorize';
44-
protected string $accessTokenURL = 'https://www.deviantart.com/oauth2/token';
45-
protected string $revokeURL = 'https://www.deviantart.com/oauth2/revoke';
46-
protected string $apiURL = 'https://www.deviantart.com/api/v1/oauth2';
47-
protected ?string $userRevokeURL = 'https://www.deviantart.com/settings/applications';
48-
protected ?string $apiDocs = 'https://www.deviantart.com/developers/';
49-
protected ?string $applicationURL = 'https://www.deviantart.com/developers/apps';
50-
protected array $apiHeaders = ['dA-minor-version' => '20210526'];
43+
protected string $authURL = 'https://www.deviantart.com/oauth2/authorize';
44+
protected string $accessTokenURL = 'https://www.deviantart.com/oauth2/token';
45+
protected string $revokeURL = 'https://www.deviantart.com/oauth2/revoke';
46+
protected string $apiURL = 'https://www.deviantart.com/api/v1/oauth2';
47+
protected string|null $userRevokeURL = 'https://www.deviantart.com/settings/applications';
48+
protected string|null $apiDocs = 'https://www.deviantart.com/developers/';
49+
protected string|null $applicationURL = 'https://www.deviantart.com/developers/apps';
50+
protected array $apiHeaders = ['dA-minor-version' => '20210526'];
5151

5252
/**
5353
* @inheritDoc
@@ -72,7 +72,7 @@ public function me():ResponseInterface{
7272
/**
7373
* @inheritDoc
7474
*/
75-
public function invalidateAccessToken(AccessToken $token = null):bool{
75+
public function invalidateAccessToken(AccessToken|null $token = null):bool{
7676

7777
if($token !== null){
7878
// to revoke a token different from the one of the currently authenticated user,

src/Discogs.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
*/
2323
class Discogs extends OAuth1Provider{
2424

25-
protected string $requestTokenURL = 'https://api.discogs.com/oauth/request_token';
26-
protected string $authURL = 'https://www.discogs.com/oauth/authorize';
27-
protected string $accessTokenURL = 'https://api.discogs.com/oauth/access_token';
28-
protected string $apiURL = 'https://api.discogs.com';
29-
protected ?string $userRevokeURL = 'https://www.discogs.com/settings/applications';
30-
protected ?string $apiDocs = 'https://www.discogs.com/developers/';
31-
protected ?string $applicationURL = 'https://www.discogs.com/settings/developers';
32-
protected array $apiHeaders = ['Accept' => 'application/vnd.discogs.v2.discogs+json'];
25+
protected string $requestTokenURL = 'https://api.discogs.com/oauth/request_token';
26+
protected string $authURL = 'https://www.discogs.com/oauth/authorize';
27+
protected string $accessTokenURL = 'https://api.discogs.com/oauth/access_token';
28+
protected string $apiURL = 'https://api.discogs.com';
29+
protected string|null $userRevokeURL = 'https://www.discogs.com/settings/applications';
30+
protected string|null $apiDocs = 'https://www.discogs.com/developers/';
31+
protected string|null $applicationURL = 'https://www.discogs.com/settings/developers';
32+
protected array $apiHeaders = ['Accept' => 'application/vnd.discogs.v2.discogs+json'];
3333

3434
/**
3535
* @inheritDoc

src/Discord.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,7 @@ class Discord extends OAuth2Provider implements ClientCredentials, CSRFToken, To
4242
public const SCOPE_RPC_NOTIFICATIONS_READ = 'rpc.notifications.read';
4343
public const SCOPE_WEBHOOK_INCOMING = 'webhook.incoming';
4444

45-
protected string $authURL = 'https://discordapp.com/api/oauth2/authorize';
46-
protected string $accessTokenURL = 'https://discordapp.com/api/oauth2/token';
47-
protected string $revokeURL = 'https://discordapp.com/api/oauth2/token/revoke';
48-
protected string $apiURL = 'https://discordapp.com/api';
49-
protected ?string $apiDocs = 'https://discordapp.com/developers/';
50-
protected ?string $applicationURL = 'https://discordapp.com/developers/applications/';
51-
52-
protected array $defaultScopes = [
45+
protected array $defaultScopes = [
5346
self::SCOPE_CONNECTIONS,
5447
self::SCOPE_EMAIL,
5548
self::SCOPE_IDENTIFY,
@@ -59,6 +52,13 @@ class Discord extends OAuth2Provider implements ClientCredentials, CSRFToken, To
5952
self::SCOPE_MESSAGES_READ,
6053
];
6154

55+
protected string $authURL = 'https://discordapp.com/api/oauth2/authorize';
56+
protected string $accessTokenURL = 'https://discordapp.com/api/oauth2/token';
57+
protected string $revokeURL = 'https://discordapp.com/api/oauth2/token/revoke';
58+
protected string $apiURL = 'https://discordapp.com/api';
59+
protected string|null $apiDocs = 'https://discordapp.com/developers/';
60+
protected string|null $applicationURL = 'https://discordapp.com/developers/applications/';
61+
6262
/**
6363
* @inheritDoc
6464
*/

src/Flickr.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@
2121
*/
2222
class Flickr extends OAuth1Provider{
2323

24-
public const PERM_READ = 'read';
25-
public const PERM_WRITE = 'write';
26-
public const PERM_DELETE = 'delete';
24+
public const PERM_READ = 'read';
25+
public const PERM_WRITE = 'write';
26+
public const PERM_DELETE = 'delete';
2727

28-
protected string $requestTokenURL = 'https://www.flickr.com/services/oauth/request_token';
29-
protected string $authURL = 'https://www.flickr.com/services/oauth/authorize';
30-
protected string $accessTokenURL = 'https://www.flickr.com/services/oauth/access_token';
31-
protected string $apiURL = 'https://api.flickr.com/services/rest';
32-
protected ?string $userRevokeURL = 'https://www.flickr.com/services/auth/list.gne';
33-
protected ?string $apiDocs = 'https://www.flickr.com/services/api/';
34-
protected ?string $applicationURL = 'https://www.flickr.com/services/apps/create/';
28+
protected string $requestTokenURL = 'https://www.flickr.com/services/oauth/request_token';
29+
protected string $authURL = 'https://www.flickr.com/services/oauth/authorize';
30+
protected string $accessTokenURL = 'https://www.flickr.com/services/oauth/access_token';
31+
protected string $apiURL = 'https://api.flickr.com/services/rest';
32+
protected string|null $userRevokeURL = 'https://www.flickr.com/services/auth/list.gne';
33+
protected string|null $apiDocs = 'https://www.flickr.com/services/api/';
34+
protected string|null $applicationURL = 'https://www.flickr.com/services/apps/create/';
3535

3636
/**
3737
* @inheritDoc
3838
*/
3939
public function request(
40-
string $path,
41-
array $params = null,
42-
string $method = null,
43-
StreamInterface|array|string $body = null,
44-
array $headers = null,
45-
string $protocolVersion = null
40+
string $path,
41+
array|null $params = null,
42+
string|null $method = null,
43+
StreamInterface|array|string|null $body = null,
44+
array|null $headers = null,
45+
string|null $protocolVersion = null
4646
):ResponseInterface{
4747

4848
$params = array_merge(($params ?? []), [

0 commit comments

Comments
 (0)