SSO client
This page contains examples with the SSO client. See the client introduction for a more detailed description how to use a client. You may also want to consider the authentication documentation to understand the many ways you can authenticate with AWS.
The SSO package could be installed with Composer.
composer require async-aws/sso
A new client object may be instantiated by:
use AsyncAws\Sso\SsoClient;
$sSO = new SSOClient();
The authentication parameters is read from the environment by default. You can also specify a AWS access id and secret:
use AsyncAws\Sso\SsoClient;
$sSO = new SSOClient([
'accessKeyId' => 'my_access_key',
'accessKeySecret' => 'my_access_secret',
'region' => 'eu-central-1',
]);
For all available options, see the configuration reference.
Usage¶
Retrieve role credentials¶
use AsyncAws\Sso\Input\GetRoleCredentialsRequest;
use AsyncAws\Sso\SsoClient;
$client = new SsoClient();
$result = $client->getRoleCredentials(new GetRoleCredentialsRequest([
'roleName' => 'YourRoleName',
'accountId' => 'YourAccountId',
'accessToken' => 'YourAccessToken',
]));
echo 'AccessKeyId:' . $result->getRoleCredentials()->getAccessKeyId().PHP_EOL;
echo 'Expiration:' . $result->getRoleCredentials()->getExpiration().PHP_EOL;
echo 'SecretAccessKey:' . $result->getRoleCredentials()->getSecretAccessKey().PHP_EOL;
echo 'SessionToken:' . $result->getRoleCredentials()->getSessionToken();
The source code to this page is found on GitHub.