Skip to content

have you example ? #2

@salegoodluck

Description

@salegoodluck

/**
* Get authenticated FBA Inbound API Instance using
* credential from the configuration
*
* @return FbaInboundApi
*/
public function getFbaInboundApiInstance(): FbaInboundApi
{
$tokenStorage = new FsTokenStorage($this->config->get('application')->get('cacheDir') . DS . '.aws-tokens');
$stsAuthenticationConfiguration = new Configuration();
$stsConfig = $this->config->get('aws')->get('sts');
$lwaConfig = $this->config->get('amazon')->get('lwa');
$spApiConfig = $this->config->get('amazon')->get('selling_partner_api');

    $stsAuthenticationConfiguration->setApiKey('refresh_token', $lwaConfig['refresh_token']);
    $stsAuthenticationConfiguration->setApiKey('client_id', $lwaConfig['client_id']);
    $stsAuthenticationConfiguration->setApiKey('client_secret', $lwaConfig['client_secret']);
    $stsAuthenticationConfiguration->setApiKey('access_key', $stsConfig['access_key']);
    $stsAuthenticationConfiguration->setApiKey('secret_key', $stsConfig['secret_key']);
    $stsAuthenticationConfiguration->setApiKey('role_arn', $stsConfig['role_arn']);
    $stsAuthenticationConfiguration->setDebug(false);

    $credential = new Credentials($tokenStorage, $stsAuthenticationConfiguration);
    // Cache and retrieve both LWA tokens and assumeRole via sts tokens
    $tokens = $credential->getCredentials();

    $config = Configuration::getDefaultConfiguration();
    $config->setAccessToken($tokens['lwa_access_token']);
    $config->setApiKey('accessKey', $tokens['sts_credentials']['access_key']);
    $config->setApiKey('secretKey', $tokens['sts_credentials']['secret_key']);
    $config->setApiKey('region', $spApiConfig['region']);
    $config->setApiKey('securityToken', $tokens['sts_credentials']['session_token']);
    $config->setDebug(false);
    $config->setHost($spApiConfig['host']);

    return new FbaInboundApi(
        new Client(),
        $config
    );
}

how can use this function getFbaInboundApiInstance ? are you wirte example ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions