Skip to content

Commit 5778fd9

Browse files
committed
:octocat: use a concrete identifier rather than random env variables
1 parent 90caa98 commit 5778fd9

File tree

143 files changed

+169
-327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+169
-327
lines changed

.config/.env_example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ TUMBLR_SECRET=
236236
TUMBLR_CALLBACK_URL=
237237
#TUMBLR_TESTUSER=
238238

239+
# this is a copy of the tumblr key for the OAuth2 client
240+
TUMBLR2_KEY=
241+
TUMBLR2_SECRET=
242+
TUMBLR2_CALLBACK_URL=
243+
#TUMBLR2_TESTUSER=
244+
239245
# https://www.twitch.tv/kraken/oauth2/clients/new
240246
TWITCH_KEY=
241247
TWITCH_SECRET=
@@ -248,6 +254,12 @@ TWITTER_SECRET=
248254
TWITTER_CALLBACK_URL=
249255
#TWITTER_TESTUSER=
250256

257+
# this is a copy of the twitter key for the OAuth2 client
258+
TWITTERCC_KEY=
259+
TWITTERCC_SECRET=
260+
TWITTERCC_CALLBACK_URL=
261+
#TWITTERCC_TESTUSER=
262+
251263
# https://developer.vimeo.com/apps/
252264
VIMEO_KEY=
253265
VIMEO_SECRET=

examples/OAuthExampleProviderFactory.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,13 @@ protected function initFileStorage():OAuthStorageInterface{
8484

8585
public function getProvider(
8686
string $providerFQN,
87-
string $envVar,
8887
int $storageType = self::STORAGE_SESSION,
8988
):OAuthInterface|OAuth1Interface|OAuth2Interface{
9089
$options = new OAuthOptions;
91-
92-
$options->key = ($this->getEnvVar($envVar.'_KEY') ?? '');
93-
$options->secret = ($this->getEnvVar($envVar.'_SECRET') ?? '');
94-
$options->callbackURL = ($this->getEnvVar($envVar.'_CALLBACK_URL') ?? '');
90+
/** @param \chillerlan\OAuth\Core\OAuthInterface $providerFQN */
91+
$options->key = ($this->getEnvVar($providerFQN::IIDENTIFIER.'_KEY') ?? '');
92+
$options->secret = ($this->getEnvVar($providerFQN::IDENTIFIER.'_SECRET') ?? '');
93+
$options->callbackURL = ($this->getEnvVar($providerFQN::IDENTIFIER.'_CALLBACK_URL') ?? '');
9594
$options->tokenAutoRefresh = true;
9695
$options->sessionStart = true;
9796

examples/Providers/GitHub/github-common.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
use chillerlan\OAuth\Providers\GitHub;
1111

12-
$ENVVAR = 'GITHUB';
13-
1412
require_once __DIR__.'/../../provider-example-common.php';
1513

1614
/** @var \OAuthExampleProviderFactory $factory */
17-
$github = $factory->getProvider(GitHub::class, $ENVVAR, OAuthExampleProviderFactory::STORAGE_FILE);
15+
$github = $factory->getProvider(GitHub::class, OAuthExampleProviderFactory::STORAGE_FILE);

examples/Providers/LastFM/lastfm-common.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
use chillerlan\OAuth\Providers\LastFM;
1212

13-
$ENVVAR = 'LASTFM';
14-
1513
require_once __DIR__.'/../../provider-example-common.php';
1614

1715
/** @var \OAuthExampleProviderFactory $factory */
18-
$lfm = $factory->getProvider(LastFM::class, $ENVVAR, OAuthExampleProviderFactory::STORAGE_FILE);
16+
$lfm = $factory->getProvider(LastFM::class, OAuthExampleProviderFactory::STORAGE_FILE);

examples/Providers/Spotify/mixesdb-track-search.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
/**
1616
* @var \OAuthExampleProviderFactory $factory
1717
* @var \chillerlan\OAuth\Providers\Spotify $spotify
18-
* @var string $ENVVAR
1918
*/
2019
require_once __DIR__.'/spotify-common.php';
2120
require_once __DIR__.'/MixesDBTrackSearch.php';
@@ -31,7 +30,7 @@
3130
include __DIR__.'/mixesdb-scrape.php';
3231
}
3332

34-
$spotify = $factory->getProvider(MixesDBTrackSearch::class, $ENVVAR, OAuthExampleProviderFactory::STORAGE_FILE);
33+
$spotify = $factory->getProvider(MixesDBTrackSearch::class, OAuthExampleProviderFactory::STORAGE_FILE);
3534
$spotify->getTracks($file, $since, $until, $find, $limit, $playlistPerSet);
3635

3736
exit;

examples/Providers/Spotify/new-releases.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
/**
1717
* @var \OAuthExampleProviderFactory $factory
1818
* @var \SpotifyNewReleases $spotify
19-
* @var string $ENVVAR
2019
*/
2120

2221
require_once __DIR__.'/spotify-common.php';
@@ -30,7 +29,7 @@
3029
$fromCache = false;
3130
$cacheDir = __DIR__.'/cache';
3231

33-
$spotify = $factory->getProvider(SpotifyNewReleases::class, $ENVVAR, OAuthExampleProviderFactory::STORAGE_FILE);
32+
$spotify = $factory->getProvider(SpotifyNewReleases::class, OAuthExampleProviderFactory::STORAGE_FILE);
3433
$spotify->getNewReleases($since, $until, $minTracks, $skipVariousArtist, $skipAppearsOn, $fromCache, $cacheDir);
3534

3635
/*

examples/Providers/Spotify/playlist-diff.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public function diff(string $playlistID1, string $playlistID2, bool $createAsPla
3434
/**
3535
* @var \OAuthExampleProviderFactory $factory
3636
* @var \PlaylistDiff $spotify
37-
* @var string $ENVVAR
3837
*/
3938

40-
$spotify = $factory->getProvider(PlaylistDiff::class, $ENVVAR, OAuthExampleProviderFactory::STORAGE_FILE);
39+
$spotify = $factory->getProvider(PlaylistDiff::class, OAuthExampleProviderFactory::STORAGE_FILE);
4140
$spotify->diff('37i9dQZF1DX4UtSsGT1Sbe', '37i9dQZF1DXb57FjYWz00c', true);

examples/Providers/Spotify/spotify-common.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313

1414
use chillerlan\OAuth\Providers\Spotify;
1515

16-
$ENVVAR = 'SPOTIFY';
17-
1816
require_once __DIR__.'/../../provider-example-common.php';
1917
require_once __DIR__.'/SpotifyClient.php';
2018

2119
/** @var \OAuthExampleProviderFactory $factory */
22-
$spotify = $factory->getProvider(Spotify::class, $ENVVAR, \OAuthExampleProviderFactory::STORAGE_FILE);
20+
$spotify = $factory->getProvider(Spotify::class, \OAuthExampleProviderFactory::STORAGE_FILE);

examples/get-token/Amazon.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
use chillerlan\OAuth\Providers\Amazon;
1313

14-
$ENVVAR ??= 'AMAZON';
15-
1614
require_once __DIR__.'/../provider-example-common.php';
1715

1816
/** @var \OAuthExampleProviderFactory $factory */
19-
$provider = $factory->getProvider(Amazon::class, $ENVVAR);
17+
$provider = $factory->getProvider(Amazon::class);
2018

2119
require_once __DIR__.'/_flow-oauth2.php';
2220

examples/get-token/BattleNet.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
use chillerlan\OAuth\Providers\BattleNet;
1313

14-
$ENVVAR ??= 'BATTLENET';
15-
1614
require_once __DIR__.'/../provider-example-common.php';
1715

1816
/** @var \OAuthExampleProviderFactory $factory */
19-
$provider = $factory->getProvider(BattleNet::class, $ENVVAR);
17+
$provider = $factory->getProvider(BattleNet::class);
2018

2119
require_once __DIR__.'/_flow-oauth2.php';
2220

0 commit comments

Comments
 (0)