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

Commit 062dd54

Browse files
committed
🚿 allow custom scopes in examples
1 parent fd0d6ed commit 062dd54

23 files changed

+50
-26
lines changed

examples/get-token/Amazon.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
* @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
23+
* @var array $SCOPES
2324
*/
2425

2526
$amazon = new Amazon($http, $storage, $options, $logger);
2627
$servicename = $amazon->serviceName;
2728

2829
// step 2: redirect to the provider's login screen
2930
if(isset($_GET['login']) && $_GET['login'] === $servicename){
30-
header('Location: '.$amazon->getAuthURL());
31+
header('Location: '.$amazon->getAuthURL(null, $SCOPES));
3132
}
3233
// step 3: receive the access token
3334
elseif(isset($_GET['code']) && isset($_GET['state'])){

examples/get-token/BattleNet.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
* @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
23+
* @var array $SCOPES
2324
*/
2425

2526
$battlenet = new BattleNet($http, $storage, $options, $logger);
2627
$servicename = $battlenet->serviceName;
2728

2829
// step 2: redirect to the provider's login screen
2930
if(isset($_GET['login']) && $_GET['login'] === $servicename){
30-
header('Location: '.$battlenet->getAuthURL());
31+
header('Location: '.$battlenet->getAuthURL(null, $SCOPES));
3132
}
3233
// step 3: receive the access token
3334
elseif(isset($_GET['code']) && isset($_GET['state'])){

examples/get-token/Deezer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
* @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
23+
* @var array $SCOPES
2324
*/
2425

2526
$deezer = new Deezer($http, $storage, $options, $logger);
2627
$servicename = $deezer->serviceName;
2728

2829
// step 2: redirect to the provider's login screen
2930
if(isset($_GET['login']) && $_GET['login'] === $servicename){
30-
header('Location: '.$deezer->getAuthURL());
31+
header('Location: '.$deezer->getAuthURL(null, $SCOPES));
3132
}
3233
// step 3: receive the access token
3334
elseif(isset($_GET['code']) && isset($_GET['state'])){

examples/get-token/DeviantArt.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
* @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
23+
* @var array $SCOPES
2324
*/
2425

2526
$deviantart = new DeviantArt($http, $storage, $options, $logger);
2627
$servicename = $deviantart->serviceName;
2728

2829
// step 2: redirect to the provider's login screen
2930
if(isset($_GET['login']) && $_GET['login'] === $servicename){
30-
header('Location: '.$deviantart->getAuthURL());
31+
header('Location: '.$deviantart->getAuthURL(null, $SCOPES));
3132
}
3233
// step 3: receive the access token
3334
elseif(isset($_GET['code']) && isset($_GET['state'])){

examples/get-token/Discord.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
* @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
23+
* @var array $SCOPES
2324
*/
2425

2526
$discord = new Discord($http, $storage, $options, $logger);
2627
$servicename = $discord->serviceName;
2728

2829
// step 2: redirect to the provider's login screen
2930
if(isset($_GET['login']) && $_GET['login'] === $servicename){
30-
header('Location: '.$discord->getAuthURL());
31+
header('Location: '.$discord->getAuthURL(null, $SCOPES));
3132
}
3233
// step 3: receive the access token
3334
elseif(isset($_GET['code']) && isset($_GET['state'])){

examples/get-token/GitHub.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
* @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
23+
* @var array $SCOPES
2324
*/
2425

2526
$github = new GitHub($http, $storage, $options, $logger);
2627
$servicename = $github->serviceName;
2728

2829
// step 2: redirect to the provider's login screen
2930
if(isset($_GET['login']) && $_GET['login'] === $servicename){
30-
header('Location: '.$github->getAuthURL());
31+
header('Location: '.$github->getAuthURL(null, $SCOPES));
3132
}
3233
// step 3: receive the access token
3334
elseif(isset($_GET['code']) && isset($_GET['state'])){

examples/get-token/Gitter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
* @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
23+
* @var array $SCOPES
2324
*/
2425

2526
$gitter = new Gitter($http, $storage, $options, $logger);
2627
$servicename = $gitter->serviceName;
2728

2829
// step 2: redirect to the provider's login screen
2930
if(isset($_GET['login']) && $_GET['login'] === $servicename){
30-
header('Location: '.$gitter->getAuthURL());
31+
header('Location: '.$gitter->getAuthURL(null, $SCOPES));
3132
}
3233
// step 3: receive the access token
3334
elseif(isset($_GET['code']) && isset($_GET['state'])){

examples/get-token/Google.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
23+
* @var array $SCOPES
2324
*/
2425

2526
$google = new Google($http, $storage, $options, $logger);
@@ -29,7 +30,7 @@
2930
if(isset($_GET['login']) && $_GET['login'] === $servicename){
3031
$params = ['access_type' => 'online'];
3132

32-
header('Location: '.$google->getAuthURL($params));
33+
header('Location: '.$google->getAuthURL($params, $SCOPES));
3334
}
3435
// step 3: receive the access token
3536
elseif(isset($_GET['code']) && isset($_GET['state'])){

examples/get-token/Instagram.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
* @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
23+
* @var array $SCOPES
2324
*/
2425

2526
$instagram = new Instagram($http, $storage, $options, $logger);
2627
$servicename = $instagram->serviceName;
2728

2829
// step 2: redirect to the provider's login screen
2930
if(isset($_GET['login']) && $_GET['login'] === $servicename){
30-
header('Location: '.$instagram->getAuthURL());
31+
header('Location: '.$instagram->getAuthURL(null, $SCOPES));
3132
}
3233
// step 3: receive the access token
3334
elseif(isset($_GET['code']) && isset($_GET['state'])){

examples/get-token/Mastodon.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* @var \chillerlan\Settings\SettingsContainerInterface $options
2222
* @var \Psr\Log\LoggerInterface $logger
2323
* @var \chillerlan\DotEnv\DotEnv $env
24+
* @var array $SCOPES
2425
*/
2526

2627
// set the mastodon instance we're about to request data from
@@ -29,7 +30,7 @@
2930

3031
// step 2: redirect to the provider's login screen
3132
if(isset($_GET['login']) && $_GET['login'] === $servicename){
32-
header('Location: '.$mastodon->getAuthURL());
33+
header('Location: '.$mastodon->getAuthURL(null, $SCOPES));
3334
}
3435
// step 3: receive the access token
3536
elseif(isset($_GET['code']) && isset($_GET['state'])){

0 commit comments

Comments
 (0)