-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
/**
* 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
Labels
No labels