diff --git a/.config/.env_example b/.config/.env_example
index 5ab2ebb..65e399f 100644
--- a/.config/.env_example
+++ b/.config/.env_example
@@ -68,7 +68,7 @@ FOURSQUARE_SECRET=
FOURSQUARE_CALLBACK_URL=
#FOURSQUARE_TESTUSER=
-# https://github.com/settings/applications/
+# https://github.com/settings/developers
GITHUB_KEY=
GITHUB_SECRET=
GITHUB_CALLBACK_URL=
diff --git a/examples/OAuthExampleProviderFactory.php b/examples/OAuthExampleProviderFactory.php
index 294eb01..f9858c1 100644
--- a/examples/OAuthExampleProviderFactory.php
+++ b/examples/OAuthExampleProviderFactory.php
@@ -28,7 +28,6 @@
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Log\LoggerInterface;
-use Psr\Log\LogLevel;
/**
*
@@ -46,9 +45,9 @@ class OAuthExampleProviderFactory{
public function __construct(
protected OAuthProviderFactory $factory,
- protected string $cfgDir = __DIR__.'/../.config',
- string $envFile = '.env',
- string $logLevel = LogLevel::INFO,
+ protected string $cfgDir,
+ string $envFile,
+ string $logLevel,
){
ini_set('date.timezone', 'UTC');
@@ -77,7 +76,7 @@ protected function initLogger(string|null $logLevel):LoggerInterface{
protected function initFileStorage():OAuthStorageInterface{
$options = new OAuthOptions;
- $options->fileStoragePath = $this->cfgDir.'/.filestorage';
+ $options->fileStoragePath = rtrim($this->cfgDir, '/\\').'/.filestorage';
return new FileStorage('oauth-example', $options, $this->logger);
}
diff --git a/examples/get-token/_flow-oauth1.php b/examples/get-token/_flow-oauth1.php
index dc075cf..b1a4ad6 100644
--- a/examples/get-token/_flow-oauth1.php
+++ b/examples/get-token/_flow-oauth1.php
@@ -48,5 +48,5 @@
}
// step 1 (optional): display a login link
else{
- echo 'connect with '.$name.'!';
+ echo 'Connect with '.$name.'!';
}
diff --git a/examples/get-token/_flow-oauth2.php b/examples/get-token/_flow-oauth2.php
index c0fdb60..d98f197 100644
--- a/examples/get-token/_flow-oauth2.php
+++ b/examples/get-token/_flow-oauth2.php
@@ -55,5 +55,5 @@
}
// step 1 (optional): display a login link
else{
- echo 'connect with '.$name.'!';
+ echo 'Connect with '.$name.'!';
}
diff --git a/examples/provider-example-common.php b/examples/provider-example-common.php
index 314d954..fc817ea 100644
--- a/examples/provider-example-common.php
+++ b/examples/provider-example-common.php
@@ -9,11 +9,10 @@
use chillerlan\OAuth\Core\OAuthInterface;
use chillerlan\OAuth\OAuthProviderFactory;
-use GuzzleHttp\Client;
-use GuzzleHttp\Psr7\HttpFactory;
+use Psr\Log\LogLevel;
/**
- * allow to use a different autoloader to make it easier to use the examples (@todo: WIP)
+ * allow to use a different autoloader to ease using the examples
*
* @var string $AUTOLOADER - path to an alternate autoloader
*/
@@ -23,26 +22,35 @@
/**
* these vars are supposed to be set before this file is included to ease testing
*
- * @var string $CFGDIR - the directory where configuration is stored (.env, cacert, tokens)
+ * @var string $CFGDIR - the directory where configuration is stored (.env, cacert, tokens)
* @var string $ENVFILE - the name of the .env file in case it differs from the default
* @var string $LOGLEVEL - log level for the test logger, use 'none' to suppress logging
* @var array|null $PARAMS - additional params to pass to getAuthorizationURL()
- * @var array|null $SCOPES - a set of scopes for the current provider (OAuth2 only)
+ * @var array|null $SCOPES - a set of scopes for the current provider
*/
$CFGDIR ??= __DIR__.'/../.config';
-$ENVFILE ??= '.env_example';
-$LOGLEVEL ??= 'info';
+$ENVFILE ??= '.env';
+$LOGLEVEL ??= LogLevel::INFO;
$PARAMS ??= null;
$SCOPES ??= null;
-$httpFactory = new HttpFactory;
-$http = new Client([
+// invoke the PSR-17 and PSR-18 instances
+$httpFactory = new \GuzzleHttp\Psr7\HttpFactory;
+$http = new \GuzzleHttp\Client([
'verify' => $CFGDIR.'/cacert.pem',
'headers' => [
'User-Agent' => OAuthInterface::USER_AGENT,
],
]);
+/*
+$httpFactory = new \chillerlan\HTTP\Psr7\HttpFactory;
+$http = new \chillerlan\HTTP\CurlClient($httpFactory, new \chillerlan\HTTP\HTTPOptions([
+ 'ca_info' => $CFGDIR.'/cacert.pem',
+ 'user_agent' => OAuthInterface::USER_AGENT,
+]));
+*/
+
$factory = new OAuthExampleProviderFactory(
new OAuthProviderFactory($http, $httpFactory, $httpFactory, $httpFactory),
$CFGDIR,
diff --git a/public/index.php b/public/index.php
index ddfc3c2..c1926e2 100644
--- a/public/index.php
+++ b/public/index.php
@@ -19,12 +19,9 @@
$CFGDIR = __DIR__.'/../.config/';
// the name of the .env file
$ENVFILE = '.env';
-// an optional prefix for the provider variables in the .env
-$ENVVAR = null;
-// optional scopes for OAuth2 providers
+// additional params to pass to getAuthorizationURL()
+$PARAMS = null;
+// optional scopes
$SCOPES = null;
require_once __DIR__.'/../examples/get-token/GitHub.php';
-
-
-
diff --git a/src/OAuthProviderFactory.php b/src/OAuthProviderFactory.php
index 9c17e18..7dc9c97 100644
--- a/src/OAuthProviderFactory.php
+++ b/src/OAuthProviderFactory.php
@@ -44,7 +44,7 @@ public function __construct(
public function getProvider(
string $providerFQN,
SettingsContainerInterface|OAuthOptions $options = new OAuthOptions,
- OAuthStorageInterface|null $storage = new MemoryStorage,
+ OAuthStorageInterface $storage = new MemoryStorage,
):OAuthInterface|OAuth1Interface|OAuth2Interface{
if(!class_exists($providerFQN)){