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

Commit d66557e

Browse files
committed
🛀 auth method cleanup
1 parent 1a29c7b commit d66557e

File tree

8 files changed

+37
-32
lines changed

8 files changed

+37
-32
lines changed

examples/create-docblocks.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
use chillerlan\OAuth\Core\{ClientCredentials, OAuth1Interface, OAuth2Interface};
1515
use Psr\Http\Message\ResponseInterface;
1616

17+
use function chillerlan\OAuth\Providers\getProviders;
18+
use function file_get_contents, file_put_contents, implode, str_replace, strpos, substr;
19+
20+
use const PHP_EOL;
21+
1722
$ENVVAR = '';
1823

1924
require_once __DIR__.'/provider-example-common.php';
@@ -30,7 +35,7 @@
3035
'----------|----------|---------------|-------|--------------------',
3136
];
3237

33-
foreach(\chillerlan\OAuth\Providers\getProviders() as $p){
38+
foreach(getProviders() as $p){
3439
/** @var \chillerlan\OAuth\Core\OAuthInterface $provider */
3540
$provider = new $p['fqcn']($http, $storage, $options, $logger);
3641

@@ -50,19 +55,18 @@
5055
$oauth = '-';
5156
}
5257

53-
$table[] =
54-
'['.$p['name'].']('.$provider->apiDocs.') '.
55-
'| [link]('.$provider->applicationURL.') '.
56-
'| '.(!$provider->userRevokeURL ? '' : '[link]('.$provider->userRevokeURL.')').
57-
'| '.$oauth.
58-
'| '.($provider instanceof ClientCredentials ? '' : '')
59-
;
58+
$table[]
59+
= '['.$p['name'].']('.$provider->apiDocs.') '.
60+
'| [link]('.$provider->applicationURL.') '.
61+
'| '.(!$provider->userRevokeURL ? '' : '[link]('.$provider->userRevokeURL.')').
62+
'| '.$oauth.
63+
'| '.($provider instanceof ClientCredentials ? '' : '');
6064

6165
}
6266

6367
$file = __DIR__.'/../README.md';
64-
$readme = \file_get_contents($file);
65-
$start = \strpos($readme, '<!--A-->')+8;
66-
$end = \strpos($readme, '<!--O-->');
68+
$readme = file_get_contents($file);
69+
$start = strpos($readme, '<!--A-->') + 8;
70+
$end = strpos($readme, '<!--O-->');
6771

68-
\file_put_contents($file, \str_replace(\substr($readme, $start, $end-$start), \PHP_EOL.\implode(\PHP_EOL, $table).\PHP_EOL, $readme));
72+
file_put_contents($file, str_replace(substr($readme, $start, $end - $start), PHP_EOL.implode(PHP_EOL, $table).PHP_EOL, $readme));

src/Deezer/Deezer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Deezer extends OAuth2Provider implements CSRFToken{
4242
protected $authURL = 'https://connect.deezer.com/oauth/auth.php';
4343
protected $accessTokenURL = 'https://connect.deezer.com/oauth/access_token.php';
4444
protected $userRevokeURL = 'https://www.deezer.com/account/apps';
45-
protected $authMethod = self::QUERY_ACCESS_TOKEN;
45+
protected $authMethod = self::AUTH_METHOD_QUERY;
4646
protected $endpointMap = DeezerEndpoints::class;
4747
protected $apiDocs = 'https://developers.deezer.com/api';
4848
protected $applicationURL = 'http://developers.deezer.com/myapps';

src/Foursquare/Foursquare.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ class Foursquare extends OAuth2Provider{
2929

3030
protected const API_VERSIONDATE = '20190225';
3131

32-
protected $apiURL = 'https://api.foursquare.com/v2';
33-
protected $authURL = 'https://foursquare.com/oauth2/authenticate';
34-
protected $accessTokenURL = 'https://foursquare.com/oauth2/access_token';
35-
protected $userRevokeURL = 'https://foursquare.com/settings/connections';
36-
protected $authMethod = self::QUERY_OAUTH_TOKEN;
37-
protected $endpointMap = FoursquareEndpoints::class;
38-
protected $apiDocs = 'https://developer.foursquare.com/docs';
39-
protected $applicationURL = 'https://foursquare.com/developers/apps';
32+
protected $apiURL = 'https://api.foursquare.com/v2';
33+
protected $authURL = 'https://foursquare.com/oauth2/authenticate';
34+
protected $accessTokenURL = 'https://foursquare.com/oauth2/access_token';
35+
protected $userRevokeURL = 'https://foursquare.com/settings/connections';
36+
protected $authMethod = self::AUTH_METHOD_QUERY;
37+
protected $authMethodQuery = 'oauth_token';
38+
protected $endpointMap = FoursquareEndpoints::class;
39+
protected $apiDocs = 'https://developer.foursquare.com/docs';
40+
protected $applicationURL = 'https://foursquare.com/developers/apps';
4041

4142
/**
4243
* @param string $path

src/Instagram/Instagram.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Instagram extends OAuth2Provider implements CSRFToken{
5656
protected $authURL = 'https://api.instagram.com/oauth/authorize';
5757
protected $accessTokenURL = 'https://api.instagram.com/oauth/access_token';
5858
protected $userRevokeURL = 'https://www.instagram.com/accounts/manage_access/';
59-
protected $authMethod = self::QUERY_ACCESS_TOKEN;
59+
protected $authMethod = self::AUTH_METHOD_QUERY;
6060
protected $endpointMap = InstagramEndpoints::class;
6161
protected $apiDocs = 'https://www.instagram.com/developer/';
6262
protected $applicationURL = 'https://www.instagram.com/developer/clients/manage/';

src/MailChimp/MailChimp.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class MailChimp extends OAuth2Provider implements CSRFToken{
3434
protected const API_BASE = 'https://%s.api.mailchimp.com/3.0';
3535
protected const METADATA_ENDPOINT = 'https://login.mailchimp.com/oauth2/metadata';
3636

37-
protected $authURL = 'https://login.mailchimp.com/oauth2/authorize';
38-
protected $accessTokenURL = 'https://login.mailchimp.com/oauth2/token';
39-
protected $endpointMap = MailChimpEndpoints::class;
40-
protected $authMethod = self::HEADER_OAUTH;
41-
protected $apiDocs = 'https://developer.mailchimp.com/';
42-
protected $applicationURL = 'https://admin.mailchimp.com/account/oauth2/';
37+
protected $authURL = 'https://login.mailchimp.com/oauth2/authorize';
38+
protected $accessTokenURL = 'https://login.mailchimp.com/oauth2/token';
39+
protected $endpointMap = MailChimpEndpoints::class;
40+
protected $authMethodHeader = 'OAuth';
41+
protected $apiDocs = 'https://developer.mailchimp.com/';
42+
protected $applicationURL = 'https://admin.mailchimp.com/account/oauth2/';
4343

4444
/**
4545
* @param \chillerlan\OAuth\Core\AccessToken|null $token

src/Mixcloud/Mixcloud.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Mixcloud extends OAuth2Provider{
2626
protected $authURL = 'https://www.mixcloud.com/oauth/authorize';
2727
protected $accessTokenURL = 'https://www.mixcloud.com/oauth/access_token';
2828
protected $userRevokeURL = 'https://www.mixcloud.com/settings/applications/';
29-
protected $authMethod = self::QUERY_ACCESS_TOKEN;
29+
protected $authMethod = self::AUTH_METHOD_QUERY;
3030
protected $endpointMap = MixcloudEndpoints::class;
3131
protected $apiDocs = 'https://www.mixcloud.com/developers/';
3232
protected $applicationURL = 'https://www.mixcloud.com/developers/create/';

src/SoundCloud/SoundCloud.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SoundCloud extends OAuth2Provider{
3030
protected $authURL = 'https://soundcloud.com/connect';
3131
protected $accessTokenURL = 'https://api.soundcloud.com/oauth2/token';
3232
protected $userRevokeURL = 'https://soundcloud.com/settings/connections';
33-
protected $authMethod = self::HEADER_OAUTH;
33+
protected $authMethodHeader = 'OAuth';
3434
protected $endpointMap = SoundCloudEndpoints::class;
3535
protected $apiDocs = 'https://developers.soundcloud.com/';
3636
protected $applicationURL = 'https://soundcloud.com/you/apps';

src/Twitch/Twitch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class Twitch extends OAuth2Provider implements ClientCredentials, CSRFToken, Tok
5555

5656
protected $authHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json'];
5757
protected $apiHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json'];
58-
protected $authMethod = self::HEADER_OAUTH; // -> https://api.twitch.tv/kraken
59-
# protected $authMethod = self::HEADER_BEARER; // -> https://api.twitch.tv/helix
58+
protected $authMethodHeader = 'OAuth'; // -> https://api.twitch.tv/kraken
59+
# protected $authMethodHeader = 'Bearer'; // -> https://api.twitch.tv/helix
6060
protected $endpointMap = TwitchEndpoints::class;
6161
protected $apiDocs = 'https://dev.twitch.tv/docs/api/reference/';
6262
protected $applicationURL = 'https://dev.twitch.tv/console/apps/create';

0 commit comments

Comments
 (0)