feat: update BaaS flow example and connector OAuth implementation
- Updated 01_baas_flow.php example to properly initialize BaaS with auth credentials - Removed unused GetTokenRequest import from AlfaBankConnector - Removed OAuth2Api interface implementation from AlfaBankConnector - Renamed resolveOauth2Config method to defaultOauthConfig in AlfaBankConnector Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -31,18 +31,23 @@ try {
|
||||
|
||||
// METHOD B: Authorization Code Flow (H2H) (REQUIRED for Nominal Accounts)
|
||||
// See examples/13_h2h_auth_service.php for the full setup
|
||||
$auth = \Apoloz\AlfaBank\AlfaBank::auth(
|
||||
clientId: 'your-client-id',
|
||||
clientSecret: 'your-client-secret',
|
||||
redirectUri: 'https://...',
|
||||
|
||||
// We re-initialize with auth credentials if we didn't pass them initially
|
||||
$baas = AlfaBank::baas(
|
||||
certificatePath: __DIR__ . '/certs/client.cer',
|
||||
privateKeyPath: __DIR__ . '/certs/private.key',
|
||||
environment: Environment::SANDBOX
|
||||
environment: Environment::SANDBOX,
|
||||
clientId: 'your-client-id',
|
||||
clientSecret: 'your-client-secret',
|
||||
redirectUri: 'https://...'
|
||||
);
|
||||
// Assuming you have a saved refresh token:
|
||||
// $auth->refreshToken('saved_refresh_token');
|
||||
|
||||
// Now you can use OAuth methods:
|
||||
// $url = $baas->getAuthorizationUrl();
|
||||
// or
|
||||
// $baas->refreshAccessToken('saved_refresh_token');
|
||||
|
||||
echo "Authentication Successful!\n";
|
||||
echo "Authentication Configured!\n";
|
||||
|
||||
// 2. Create a Beneficiary (Counterparty)
|
||||
echo "Creating Beneficiary...\n";
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace Apoloz\AlfaBank\Core;
|
||||
use Apoloz\AlfaBank\Contracts\SignerInterface;
|
||||
use Apoloz\AlfaBank\Http\Middleware\RequestIdMiddleware;
|
||||
use Apoloz\AlfaBank\Http\Pagination\AlfaOffsetPaginator;
|
||||
use Apoloz\AlfaBank\Requests\Auth\GetTokenRequest; // Will be removed
|
||||
use Apoloz\AlfaBank\Traits\HasAlfaErrorHandling;
|
||||
use Saloon\Helpers\OAuth2\OAuthConfig;
|
||||
use Saloon\Http\Connector;
|
||||
@@ -19,11 +18,10 @@ use Saloon\PaginationPlugin\OffsetPaginator;
|
||||
use Saloon\Traits\Plugins\AlwaysThrowOnErrors;
|
||||
use Saloon\Traits\RequestProperties\HasTries;
|
||||
use Saloon\Traits\Plugins\HasTimeout;
|
||||
use Saloon\Contracts\OAuth2\OAuth2Api;
|
||||
use Saloon\Traits\OAuth2\AuthorizationCodeGrant;
|
||||
use Apoloz\AlfaBank\Enums\Environment;
|
||||
|
||||
class AlfaBankConnector extends Connector implements HasPagination, OAuth2Api
|
||||
class AlfaBankConnector extends Connector implements HasPagination
|
||||
{
|
||||
use HasTimeout;
|
||||
use HasTries;
|
||||
@@ -44,7 +42,7 @@ class AlfaBankConnector extends Connector implements HasPagination, OAuth2Api
|
||||
return $this->alfaConfig->baseUrl;
|
||||
}
|
||||
|
||||
protected function resolveOauth2Config(): OAuthConfig
|
||||
protected function defaultOauthConfig(): OAuthConfig
|
||||
{
|
||||
$idUrl = $this->alfaConfig->baseUrl === Environment::PRODUCTION->value
|
||||
? Environment::ID_PRODUCTION->value
|
||||
|
||||
Reference in New Issue
Block a user