SSOOIDC client
This page contains examples with the SSOOIDC 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 SSOOIDC package could be installed with Composer.
composer require async-aws/sso-oidc
A new client object may be instantiated by:
use AsyncAws\Sso\SsoOidcClient;
$sSOOIDC = new SSOOIDCClient();
The authentication parameters is read from the environment by default. You can also specify a AWS access id and secret:
use AsyncAws\Sso\SsoOidcClient;
$sSOOIDC = new SSOOIDCClient([
'accessKeyId' => 'my_access_key',
'accessKeySecret' => 'my_access_secret',
'region' => 'eu-central-1',
]);
For all available options, see the configuration reference.
Usage¶
Create a token¶
use AsyncAws\SsoOidc\Input\CreateToken;
use AsyncAws\SsoOidc\SsoOidcClient;
$client = new SsoOidcClient();
$result = $client->createToken(new CreateToken([
'clientId' => 'YourClientId',
'clientSecret' => 'YourClientSecret',
'grantType' => 'authorization_code',
]));
echo 'AccessToken:' . $result->getAccessToken().PHP_EOL;
echo 'Expiration:' . $result->getExpiresIn().PHP_EOL;
The source code to this page is found on GitHub.