SDK for PHP 3.x

Client: Aws\SSOOIDC\SSOOIDCClient
Service ID: sso-oidc
Version: 2019-06-10

This page describes the parameters and results for the operations of the AWS SSO OIDC (2019-06-10), and shows how to use the Aws\SSOOIDC\SSOOIDCClient object to call the described operations. This documentation is specific to the 2019-06-10 API version of the service.

Operation Summary

Each of the following operations can be created from a client using $client->getCommand('CommandName'), where "CommandName" is the name of one of the following operations. Note: a command is a value that encapsulates an operation and the parameters used to create an HTTP request.

You can also create and send a command immediately using the magic methods available on a client object: $client->commandName(/* parameters */). You can send the command asynchronously (returning a promise) by appending the word "Async" to the operation name: $client->commandNameAsync(/* parameters */).

CreateToken ( array $params = [] )
Creates and returns access and refresh tokens for clients that are authenticated using client secrets.
CreateTokenWithIAM ( array $params = [] )
Creates and returns access and refresh tokens for clients and applications that are authenticated using IAM entities.
RegisterClient ( array $params = [] )
Registers a client with IAM Identity Center.
StartDeviceAuthorization ( array $params = [] )
Initiates device authorization by requesting a pair of verification codes from the authorization service.

Operations

CreateToken

$result = $client->createToken([/* ... */]);
$promise = $client->createTokenAsync([/* ... */]);

Creates and returns access and refresh tokens for clients that are authenticated using client secrets. The access token can be used to fetch short-term credentials for the assigned AWS accounts or to access application APIs using bearer authentication.

Parameter Syntax

$result = $client->createToken([
    'clientId' => '<string>', // REQUIRED
    'clientSecret' => '<string>', // REQUIRED
    'code' => '<string>',
    'codeVerifier' => '<string>',
    'deviceCode' => '<string>',
    'grantType' => '<string>', // REQUIRED
    'redirectUri' => '<string>',
    'refreshToken' => '<string>',
    'scope' => ['<string>', ...],
]);

Parameter Details

Members
clientId
Required: Yes
Type: string

The unique identifier string for the client or application. This value comes from the result of the RegisterClient API.

clientSecret
Required: Yes
Type: string

A secret string generated for the client. This value should come from the persisted result of the RegisterClient API.

code
Type: string

Used only when calling this API for the Authorization Code grant type. The short-term code is used to identify this authorization request. This grant type is currently unsupported for the CreateToken API.

codeVerifier
Type: string

Used only when calling this API for the Authorization Code grant type. This value is generated by the client and presented to validate the original code challenge value the client passed at authorization time.

deviceCode
Type: string

Used only when calling this API for the Device Code grant type. This short-term code is used to identify this authorization request. This comes from the result of the StartDeviceAuthorization API.

grantType
Required: Yes
Type: string

Supports the following OAuth grant types: Device Code and Refresh Token. Specify either of the following values, depending on the grant type that you want:

* Device Code - urn:ietf:params:oauth:grant-type:device_code

* Refresh Token - refresh_token

For information about how to obtain the device code, see the StartDeviceAuthorization topic.

redirectUri
Type: string

Used only when calling this API for the Authorization Code grant type. This value specifies the location of the client or application that has registered to receive the authorization code.

refreshToken
Type: string

Used only when calling this API for the Refresh Token grant type. This token is used to refresh short-term tokens, such as the access token, that might expire.

For more information about the features and limitations of the current IAM Identity Center OIDC implementation, see Considerations for Using this Guide in the IAM Identity Center OIDC API Reference.

scope
Type: Array of strings

The list of scopes for which authorization is requested. The access token that is issued is limited to the scopes that are granted. If this value is not specified, IAM Identity Center authorizes all scopes that are configured for the client during the call to RegisterClient.

Result Syntax

[
    'accessToken' => '<string>',
    'expiresIn' => <integer>,
    'idToken' => '<string>',
    'refreshToken' => '<string>',
    'tokenType' => '<string>',
]

Result Details

Members
accessToken
Type: string

A bearer token to access Amazon Web Services accounts and applications assigned to a user.

expiresIn
Type: int

Indicates the time in seconds when an access token will expire.

idToken
Type: string

The idToken is not implemented or supported. For more information about the features and limitations of the current IAM Identity Center OIDC implementation, see Considerations for Using this Guide in the IAM Identity Center OIDC API Reference.

A JSON Web Token (JWT) that identifies who is associated with the issued access token.

refreshToken
Type: string

A token that, if present, can be used to refresh a previously issued access token that might have expired.

For more information about the features and limitations of the current IAM Identity Center OIDC implementation, see Considerations for Using this Guide in the IAM Identity Center OIDC API Reference.

tokenType
Type: string

Used to notify the client that the returned token is an access token. The supported token type is Bearer.

Errors

InvalidRequestException:

Indicates that something is wrong with the input to the request. For example, a required parameter might be missing or out of range.

InvalidClientException:

Indicates that the clientId or clientSecret in the request is invalid. For example, this can occur when a client sends an incorrect clientId or an expired clientSecret.

InvalidGrantException:

Indicates that a request contains an invalid grant. This can occur if a client makes a CreateToken request with an invalid grant type.

UnauthorizedClientException:

Indicates that the client is not currently authorized to make the request. This can happen when a clientId is not issued for a public client.

UnsupportedGrantTypeException:

Indicates that the grant type in the request is not supported by the service.

InvalidScopeException:

Indicates that the scope provided in the request is invalid.

AuthorizationPendingException:

Indicates that a request to authorize a client with an access user session token is pending.

SlowDownException:

Indicates that the client is making the request too frequently and is more than the service can handle.

AccessDeniedException:

You do not have sufficient access to perform this action.

ExpiredTokenException:

Indicates that the token issued by the service is expired and is no longer valid.

InternalServerException:

Indicates that an error from the service occurred while trying to process a request.

Examples

Example 1: Call OAuth/OIDC /token endpoint for Device Code grant with Secret authentication

$result = $client->createToken([
    'clientId' => '_yzkThXVzLWVhc3QtMQEXAMPLECLIENTID',
    'clientSecret' => 'VERYLONGSECRETeyJraWQiOiJrZXktMTU2NDAyODA5OSIsImFsZyI6IkhTMzg0In0',
    'deviceCode' => 'yJraWQiOiJrZXktMTU2Njk2ODA4OCIsImFsZyI6IkhTMzIn0EXAMPLEDEVICECODE',
    'grantType' => 'urn:ietf:params:oauth:grant-type:device-code',
]);

Result syntax:

[
    'accessToken' => 'aoal-YigITUDiNX1xZwOMXM5MxOWDL0E0jg9P6_C_jKQPxS_SKCP6f0kh1Up4g7TtvQqkMnD-GJiU_S1gvug6SrggAkc0:MGYCMQD3IatVjV7jAJU91kK3PkS/SfA2wtgWzOgZWDOR7sDGN9t0phCZz5It/aes/3C1Zj0CMQCKWOgRaiz6AIhza3DSXQNMLjRKXC8F8ceCsHlgYLMZ7hZidEXAMPLEACCESSTOKEN',
    'expiresIn' => 1579729529,
    'refreshToken' => 'aorvJYubGpU6i91YnH7Mfo-AT2fIVa1zCfA_Rvq9yjVKIP3onFmmykuQ7E93y2I-9Nyj-A_sVvMufaLNL0bqnDRtgAkc0:MGUCMFrRsktMRVlWaOR70XGMFGLL0SlcCw4DiYveIiOVx1uK9BbD0gvAddsW3UTLozXKMgIxAJ3qxUvjpnlLIOaaKOoa/FuNgqJVvr9GMwDtnAtlh9iZzAkEXAMPLEREFRESHTOKEN',
    'tokenType' => 'Bearer',
]
Example 2: Call OAuth/OIDC /token endpoint for Refresh Token grant with Secret authentication

$result = $client->createToken([
    'clientId' => '_yzkThXVzLWVhc3QtMQEXAMPLECLIENTID',
    'clientSecret' => 'VERYLONGSECRETeyJraWQiOiJrZXktMTU2NDAyODA5OSIsImFsZyI6IkhTMzg0In0',
    'grantType' => 'refresh_token',
    'refreshToken' => 'aorvJYubGpU6i91YnH7Mfo-AT2fIVa1zCfA_Rvq9yjVKIP3onFmmykuQ7E93y2I-9Nyj-A_sVvMufaLNL0bqnDRtgAkc0:MGUCMFrRsktMRVlWaOR70XGMFGLL0SlcCw4DiYveIiOVx1uK9BbD0gvAddsW3UTLozXKMgIxAJ3qxUvjpnlLIOaaKOoa/FuNgqJVvr9GMwDtnAtlh9iZzAkEXAMPLEREFRESHTOKEN',
    'scope' => [
        'codewhisperer:completions',
    ],
]);

Result syntax:

[
    'accessToken' => 'aoal-YigITUDiNX1xZwOMXM5MxOWDL0E0jg9P6_C_jKQPxS_SKCP6f0kh1Up4g7TtvQqkMnD-GJiU_S1gvug6SrggAkc0:MGYCMQD3IatVjV7jAJU91kK3PkS/SfA2wtgWzOgZWDOR7sDGN9t0phCZz5It/aes/3C1Zj0CMQCKWOgRaiz6AIhza3DSXQNMLjRKXC8F8ceCsHlgYLMZ7hZidEXAMPLEACCESSTOKEN',
    'expiresIn' => 1579729529,
    'refreshToken' => 'aorvJYubGpU6i91YnH7Mfo-AT2fIVa1zCfA_Rvq9yjVKIP3onFmmykuQ7E93y2I-9Nyj-A_sVvMufaLNL0bqnDRtgAkc0:MGUCMFrRsktMRVlWaOR70XGMFGLL0SlcCw4DiYveIiOVx1uK9BbD0gvAddsW3UTLozXKMgIxAJ3qxUvjpnlLIOaaKOoa/FuNgqJVvr9GMwDtnAtlh9iZzAkEXAMPLEREFRESHTOKEN',
    'tokenType' => 'Bearer',
]

CreateTokenWithIAM

$result = $client->createTokenWithIAM([/* ... */]);
$promise = $client->createTokenWithIAMAsync([/* ... */]);

Creates and returns access and refresh tokens for clients and applications that are authenticated using IAM entities. The access token can be used to fetch short-term credentials for the assigned Amazon Web Services accounts or to access application APIs using bearer authentication.

Parameter Syntax

$result = $client->createTokenWithIAM([
    'assertion' => '<string>',
    'clientId' => '<string>', // REQUIRED
    'code' => '<string>',
    'codeVerifier' => '<string>',
    'grantType' => '<string>', // REQUIRED
    'redirectUri' => '<string>',
    'refreshToken' => '<string>',
    'requestedTokenType' => '<string>',
    'scope' => ['<string>', ...],
    'subjectToken' => '<string>',
    'subjectTokenType' => '<string>',
]);

Parameter Details

Members
assertion
Type: string

Used only when calling this API for the JWT Bearer grant type. This value specifies the JSON Web Token (JWT) issued by a trusted token issuer. To authorize a trusted token issuer, configure the JWT Bearer GrantOptions for the application.

clientId
Required: Yes
Type: string

The unique identifier string for the client or application. This value is an application ARN that has OAuth grants configured.

code
Type: string

Used only when calling this API for the Authorization Code grant type. This short-term code is used to identify this authorization request. The code is obtained through a redirect from IAM Identity Center to a redirect URI persisted in the Authorization Code GrantOptions for the application.

codeVerifier
Type: string

Used only when calling this API for the Authorization Code grant type. This value is generated by the client and presented to validate the original code challenge value the client passed at authorization time.

grantType
Required: Yes
Type: string

Supports the following OAuth grant types: Authorization Code, Refresh Token, JWT Bearer, and Token Exchange. Specify one of the following values, depending on the grant type that you want:

* Authorization Code - authorization_code

* Refresh Token - refresh_token

* JWT Bearer - urn:ietf:params:oauth:grant-type:jwt-bearer

* Token Exchange - urn:ietf:params:oauth:grant-type:token-exchange

redirectUri
Type: string

Used only when calling this API for the Authorization Code grant type. This value specifies the location of the client or application that has registered to receive the authorization code.

refreshToken
Type: string

Used only when calling this API for the Refresh Token grant type. This token is used to refresh short-term tokens, such as the access token, that might expire.

For more information about the features and limitations of the current IAM Identity Center OIDC implementation, see Considerations for Using this Guide in the IAM Identity Center OIDC API Reference.

requestedTokenType
Type: string

Used only when calling this API for the Token Exchange grant type. This value specifies the type of token that the requester can receive. The following values are supported:

* Access Token - urn:ietf:params:oauth:token-type:access_token

* Refresh Token - urn:ietf:params:oauth:token-type:refresh_token

scope
Type: Array of strings

The list of scopes for which authorization is requested. The access token that is issued is limited to the scopes that are granted. If the value is not specified, IAM Identity Center authorizes all scopes configured for the application, including the following default scopes: openid, aws, sts:identity_context.

subjectToken
Type: string

Used only when calling this API for the Token Exchange grant type. This value specifies the subject of the exchange. The value of the subject token must be an access token issued by IAM Identity Center to a different client or application. The access token must have authorized scopes that indicate the requested application as a target audience.

subjectTokenType
Type: string

Used only when calling this API for the Token Exchange grant type. This value specifies the type of token that is passed as the subject of the exchange. The following value is supported:

* Access Token - urn:ietf:params:oauth:token-type:access_token

Result Syntax

[
    'accessToken' => '<string>',
    'expiresIn' => <integer>,
    'idToken' => '<string>',
    'issuedTokenType' => '<string>',
    'refreshToken' => '<string>',
    'scope' => ['<string>', ...],
    'tokenType' => '<string>',
]

Result Details

Members
accessToken
Type: string

A bearer token to access Amazon Web Services accounts and applications assigned to a user.

expiresIn
Type: int

Indicates the time in seconds when an access token will expire.

idToken
Type: string

A JSON Web Token (JWT) that identifies the user associated with the issued access token.

issuedTokenType
Type: string

Indicates the type of tokens that are issued by IAM Identity Center. The following values are supported:

* Access Token - urn:ietf:params:oauth:token-type:access_token

* Refresh Token - urn:ietf:params:oauth:token-type:refresh_token

refreshToken
Type: string

A token that, if present, can be used to refresh a previously issued access token that might have expired.

For more information about the features and limitations of the current IAM Identity Center OIDC implementation, see Considerations for Using this Guide in the IAM Identity Center OIDC API Reference.

scope
Type: Array of strings

The list of scopes for which authorization is granted. The access token that is issued is limited to the scopes that are granted.

tokenType
Type: string

Used to notify the requester that the returned token is an access token. The supported token type is Bearer.

Errors

InvalidRequestException:

Indicates that something is wrong with the input to the request. For example, a required parameter might be missing or out of range.

InvalidClientException:

Indicates that the clientId or clientSecret in the request is invalid. For example, this can occur when a client sends an incorrect clientId or an expired clientSecret.

InvalidGrantException:

Indicates that a request contains an invalid grant. This can occur if a client makes a CreateToken request with an invalid grant type.

UnauthorizedClientException:

Indicates that the client is not currently authorized to make the request. This can happen when a clientId is not issued for a public client.

UnsupportedGrantTypeException:

Indicates that the grant type in the request is not supported by the service.

InvalidScopeException:

Indicates that the scope provided in the request is invalid.

AuthorizationPendingException:

Indicates that a request to authorize a client with an access user session token is pending.

SlowDownException:

Indicates that the client is making the request too frequently and is more than the service can handle.

AccessDeniedException:

You do not have sufficient access to perform this action.

ExpiredTokenException:

Indicates that the token issued by the service is expired and is no longer valid.

InternalServerException:

Indicates that an error from the service occurred while trying to process a request.

InvalidRequestRegionException:

Indicates that a token provided as input to the request was issued by and is only usable by calling IAM Identity Center endpoints in another region.

Examples

Example 1: Call OAuth/OIDC /token endpoint for Authorization Code grant with IAM authentication

$result = $client->createTokenWithIAM([
    'clientId' => 'arn:aws:sso::123456789012:application/ssoins-111111111111/apl-222222222222',
    'code' => 'yJraWQiOiJrZXktMTU2Njk2ODA4OCIsImFsZyI6IkhTMzg0In0EXAMPLEAUTHCODE',
    'grantType' => 'authorization_code',
    'redirectUri' => 'https://mywebapp.example/redirect',
    'scope' => [
        'openid',
        'aws',
        'sts:identity_context',
    ],
]);

Result syntax:

[
    'accessToken' => 'aoal-YigITUDiNX1xZwOMXM5MxOWDL0E0jg9P6_C_jKQPxS_SKCP6f0kh1Up4g7TtvQqkMnD-GJiU_S1gvug6SrggAkc0:MGYCMQD3IatVjV7jAJU91kK3PkS/SfA2wtgWzOgZWDOR7sDGN9t0phCZz5It/aes/3C1Zj0CMQCKWOgRaiz6AIhza3DSXQNMLjRKXC8F8ceCsHlgYLMZ7hZidEXAMPLEACCESSTOKEN',
    'expiresIn' => 1579729529,
    'idToken' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhd3M6aWRlbnRpdHlfc3RvcmVfaWQiOiJkLTMzMzMzMzMzMzMiLCJzdWIiOiI3MzA0NDhmMi1lMGExLTcwYTctYzk1NC0wMDAwMDAwMDAwMDAiLCJhd3M6aW5zdGFuY2VfYWNjb3VudCI6IjExMTExMTExMTExMSIsInN0czppZGVudGl0eV9jb250ZXh0IjoiRVhBTVBMRUlERU5USVRZQ09OVEVYVCIsInN0czphdWRpdF9jb250ZXh0IjoiRVhBTVBMRUFVRElUQ09OVEVYVCIsImlzcyI6Imh0dHBzOi8vaWRlbnRpdHljZW50ZXIuYW1hem9uYXdzLmNvbS9zc29pbnMtMTExMTExMTExMTExIiwiYXdzOmlkZW50aXR5X3N0b3JlX2FybiI6ImFybjphd3M6aWRlbnRpdHlzdG9yZTo6MTExMTExMTExMTExOmlkZW50aXR5c3RvcmUvZC0zMzMzMzMzMzMzIiwiYXVkIjoiYXJuOmF3czpzc286OjEyMzQ1Njc4OTAxMjphcHBsaWNhdGlvbi9zc29pbnMtMTExMTExMTExMTExL2FwbC0yMjIyMjIyMjIyMjIiLCJhd3M6aW5zdGFuY2VfYXJuIjoiYXJuOmF3czpzc286OjppbnN0YW5jZS9zc29pbnMtMTExMTExMTExMTExIiwiYXdzOmNyZWRlbnRpYWxfaWQiOiJfWlIyTjZhVkJqMjdGUEtheWpfcEtwVjc3QVBERl80MXB4ZXRfWWpJdUpONlVJR2RBdkpFWEFNUExFQ1JFRElEIiwiYXV0aF90aW1lIjoiMjAyMC0wMS0yMlQxMjo0NToyOVoiLCJleHAiOjE1Nzk3Mjk1MjksImlhdCI6MTU3OTcyNTkyOX0.Xyah6qbk78qThzJ41iFU2yfGuRqqtKXHrJYwQ8L9Ip0',
    'issuedTokenType' => 'urn:ietf:params:oauth:token-type:refresh_token',
    'refreshToken' => 'aorvJYubGpU6i91YnH7Mfo-AT2fIVa1zCfA_Rvq9yjVKIP3onFmmykuQ7E93y2I-9Nyj-A_sVvMufaLNL0bqnDRtgAkc0:MGUCMFrRsktMRVlWaOR70XGMFGLL0SlcCw4DiYveIiOVx1uK9BbD0gvAddsW3UTLozXKMgIxAJ3qxUvjpnlLIOaaKOoa/FuNgqJVvr9GMwDtnAtlh9iZzAkEXAMPLEREFRESHTOKEN',
    'scope' => [
        'openid',
        'aws',
        'sts:identity_context',
    ],
    'tokenType' => 'Bearer',
]
Example 2: Call OAuth/OIDC /token endpoint for Refresh Token grant with IAM authentication

$result = $client->createTokenWithIAM([
    'clientId' => 'arn:aws:sso::123456789012:application/ssoins-111111111111/apl-222222222222',
    'grantType' => 'refresh_token',
    'refreshToken' => 'aorvJYubGpU6i91YnH7Mfo-AT2fIVa1zCfA_Rvq9yjVKIP3onFmmykuQ7E93y2I-9Nyj-A_sVvMufaLNL0bqnDRtgAkc0:MGUCMFrRsktMRVlWaOR70XGMFGLL0SlcCw4DiYveIiOVx1uK9BbD0gvAddsW3UTLozXKMgIxAJ3qxUvjpnlLIOaaKOoa/FuNgqJVvr9GMwDtnAtlh9iZzAkEXAMPLEREFRESHTOKEN',
]);

Result syntax:

[
    'accessToken' => 'aoal-YigITUDiNX1xZwOMXM5MxOWDL0E0jg9P6_C_jKQPxS_SKCP6f0kh1Up4g7TtvQqkMnD-GJiU_S1gvug6SrggAkc0:MGYCMQD3IatVjV7jAJU91kK3PkS/SfA2wtgWzOgZWDOR7sDGN9t0phCZz5It/aes/3C1Zj0CMQCKWOgRaiz6AIhza3DSXQNMLjRKXC8F8ceCsHlgYLMZ7hZidEXAMPLEACCESSTOKEN',
    'expiresIn' => 1579729529,
    'issuedTokenType' => 'urn:ietf:params:oauth:token-type:refresh_token',
    'refreshToken' => 'aorvJYubGpU6i91YnH7Mfo-AT2fIVa1zCfA_Rvq9yjVKIP3onFmmykuQ7E93y2I-9Nyj-A_sVvMufaLNL0bqnDRtgAkc0:MGUCMFrRsktMRVlWaOR70XGMFGLL0SlcCw4DiYveIiOVx1uK9BbD0gvAddsW3UTLozXKMgIxAJ3qxUvjpnlLIOaaKOoa/FuNgqJVvr9GMwDtnAtlh9iZzAkEXAMPLEREFRESHTOKEN',
    'scope' => [
        'openid',
        'aws',
        'sts:identity_context',
    ],
    'tokenType' => 'Bearer',
]
Example 3: Call OAuth/OIDC /token endpoint for JWT Bearer grant with IAM authentication

$result = $client->createTokenWithIAM([
    'assertion' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjFMVE16YWtpaGlSbGFfOHoyQkVKVlhlV01xbyJ9.eyJ2ZXIiOiIyLjAiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vOTEyMjA0MGQtNmM2Ny00YzViLWIxMTItMzZhMzA0YjY2ZGFkL3YyLjAiLCJzdWIiOiJBQUFBQUFBQUFBQUFBQUFBQUFBQUFJa3pxRlZyU2FTYUZIeTc4MmJidGFRIiwiYXVkIjoiNmNiMDQwMTgtYTNmNS00NmE3LWI5OTUtOTQwYzc4ZjVhZWYzIiwiZXhwIjoxNTM2MzYxNDExLCJpYXQiOjE1MzYyNzQ3MTEsIm5iZiI6MTUzNjI3NDcxMSwibmFtZSI6IkFiZSBMaW5jb2xuIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiQWJlTGlAbWljcm9zb2Z0LmNvbSIsIm9pZCI6IjAwMDAwMDAwLTAwMDAtMDAwMC02NmYzLTMzMzJlY2E3ZWE4MSIsInRpZCI6IjkxMjIwNDBkLTZjNjctNGM1Yi1iMTEyLTM2YTMwNGI2NmRhZCIsIm5vbmNlIjoiMTIzNTIzIiwiYWlvIjoiRGYyVVZYTDFpeCFsTUNXTVNPSkJjRmF0emNHZnZGR2hqS3Y4cTVnMHg3MzJkUjVNQjVCaXN2R1FPN1lXQnlqZDhpUURMcSFlR2JJRGFreXA1bW5PcmNkcUhlWVNubHRlcFFtUnA2QUlaOGpZIn0.1AFWW-Ck5nROwSlltm7GzZvDwUkqvhSQpm55TQsmVo9Y59cLhRXpvB8n-55HCr9Z6G_31_UbeUkoz612I2j_Sm9FFShSDDjoaLQr54CreGIJvjtmS3EkK9a7SJBbcpL1MpUtlfygow39tFjY7EVNW9plWUvRrTgVk7lYLprvfzw-CIqw3gHC-T7IK_m_xkr08INERBtaecwhTeN4chPC4W3jdmw_lIxzC48YoQ0dB1L9-ImX98Egypfrlbm0IBL5spFzL6JDZIRRJOu8vecJvj1mq-IUhGt0MacxX8jdxYLP-KUu2d9MbNKpCKJuZ7p8gwTL5B7NlUdh_dmSviPWrw',
    'clientId' => 'arn:aws:sso::123456789012:application/ssoins-111111111111/apl-222222222222',
    'grantType' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
]);

Result syntax:

[
    'accessToken' => 'aoal-YigITUDiNX1xZwOMXM5MxOWDL0E0jg9P6_C_jKQPxS_SKCP6f0kh1Up4g7TtvQqkMnD-GJiU_S1gvug6SrggAkc0:MGYCMQD3IatVjV7jAJU91kK3PkS/SfA2wtgWzOgZWDOR7sDGN9t0phCZz5It/aes/3C1Zj0CMQCKWOgRaiz6AIhza3DSXQNMLjRKXC8F8ceCsHlgYLMZ7hZidEXAMPLEACCESSTOKEN',
    'expiresIn' => 1579729529,
    'idToken' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhd3M6aWRlbnRpdHlfc3RvcmVfaWQiOiJkLTMzMzMzMzMzMzMiLCJzdWIiOiI3MzA0NDhmMi1lMGExLTcwYTctYzk1NC0wMDAwMDAwMDAwMDAiLCJhd3M6aW5zdGFuY2VfYWNjb3VudCI6IjExMTExMTExMTExMSIsInN0czppZGVudGl0eV9jb250ZXh0IjoiRVhBTVBMRUlERU5USVRZQ09OVEVYVCIsInN0czphdWRpdF9jb250ZXh0IjoiRVhBTVBMRUFVRElUQ09OVEVYVCIsImlzcyI6Imh0dHBzOi8vaWRlbnRpdHljZW50ZXIuYW1hem9uYXdzLmNvbS9zc29pbnMtMTExMTExMTExMTExIiwiYXdzOmlkZW50aXR5X3N0b3JlX2FybiI6ImFybjphd3M6aWRlbnRpdHlzdG9yZTo6MTExMTExMTExMTExOmlkZW50aXR5c3RvcmUvZC0zMzMzMzMzMzMzIiwiYXVkIjoiYXJuOmF3czpzc286OjEyMzQ1Njc4OTAxMjphcHBsaWNhdGlvbi9zc29pbnMtMTExMTExMTExMTExL2FwbC0yMjIyMjIyMjIyMjIiLCJhd3M6aW5zdGFuY2VfYXJuIjoiYXJuOmF3czpzc286OjppbnN0YW5jZS9zc29pbnMtMTExMTExMTExMTExIiwiYXdzOmNyZWRlbnRpYWxfaWQiOiJfWlIyTjZhVkJqMjdGUEtheWpfcEtwVjc3QVBERl80MXB4ZXRfWWpJdUpONlVJR2RBdkpFWEFNUExFQ1JFRElEIiwiYXV0aF90aW1lIjoiMjAyMC0wMS0yMlQxMjo0NToyOVoiLCJleHAiOjE1Nzk3Mjk1MjksImlhdCI6MTU3OTcyNTkyOX0.Xyah6qbk78qThzJ41iFU2yfGuRqqtKXHrJYwQ8L9Ip0',
    'issuedTokenType' => 'urn:ietf:params:oauth:token-type:refresh_token',
    'refreshToken' => 'aorvJYubGpU6i91YnH7Mfo-AT2fIVa1zCfA_Rvq9yjVKIP3onFmmykuQ7E93y2I-9Nyj-A_sVvMufaLNL0bqnDRtgAkc0:MGUCMFrRsktMRVlWaOR70XGMFGLL0SlcCw4DiYveIiOVx1uK9BbD0gvAddsW3UTLozXKMgIxAJ3qxUvjpnlLIOaaKOoa/FuNgqJVvr9GMwDtnAtlh9iZzAkEXAMPLEREFRESHTOKEN',
    'scope' => [
        'openid',
        'aws',
        'sts:identity_context',
    ],
    'tokenType' => 'Bearer',
]
Example 4: Call OAuth/OIDC /token endpoint for Token Exchange grant with IAM authentication

$result = $client->createTokenWithIAM([
    'clientId' => 'arn:aws:sso::123456789012:application/ssoins-111111111111/apl-222222222222',
    'grantType' => 'urn:ietf:params:oauth:grant-type:token-exchange',
    'requestedTokenType' => 'urn:ietf:params:oauth:token-type:access_token',
    'subjectToken' => 'aoak-Hig8TUDPNX1xZwOMXM5MxOWDL0E0jg9P6_C_jKQPxS_SKCP6f0kh1Up4g7TtvQqkMnD-GJiU_S1gvug6SrggAkc0:MGYCMQD3IatVjV7jAJU91kK3PkS/SfA2wtgWzOgZWDOR7sDGN9t0phCZz5It/aes/3C1Zj0CMQCKWOgRaiz6AIhza3DSXQNMLjRKXC8F8ceCsHlgYLMZ7hZDIFFERENTACCESSTOKEN',
    'subjectTokenType' => 'urn:ietf:params:oauth:token-type:access_token',
]);

Result syntax:

[
    'accessToken' => 'aoal-YigITUDiNX1xZwOMXM5MxOWDL0E0jg9P6_C_jKQPxS_SKCP6f0kh1Up4g7TtvQqkMnD-GJiU_S1gvug6SrggAkc0:MGYCMQD3IatVjV7jAJU91kK3PkS/SfA2wtgWzOgZWDOR7sDGN9t0phCZz5It/aes/3C1Zj0CMQCKWOgRaiz6AIhza3DSXQNMLjRKXC8F8ceCsHlgYLMZ7hZidEXAMPLEACCESSTOKEN',
    'expiresIn' => 1579729529,
    'idToken' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhd3M6aWRlbnRpdHlfc3RvcmVfaWQiOiJkLTMzMzMzMzMzMzMiLCJzdWIiOiI3MzA0NDhmMi1lMGExLTcwYTctYzk1NC0wMDAwMDAwMDAwMDAiLCJhd3M6aW5zdGFuY2VfYWNjb3VudCI6IjExMTExMTExMTExMSIsInN0czppZGVudGl0eV9jb250ZXh0IjoiRVhBTVBMRUlERU5USVRZQ09OVEVYVCIsImlzcyI6Imh0dHBzOi8vaWRlbnRpdHljZW50ZXIuYW1hem9uYXdzLmNvbS9zc29pbnMtMTExMTExMTExMTExIiwiYXdzOmlkZW50aXR5X3N0b3JlX2FybiI6ImFybjphd3M6aWRlbnRpdHlzdG9yZTo6MTExMTExMTExMTExOmlkZW50aXR5c3RvcmUvZC0zMzMzMzMzMzMzIiwiYXVkIjoiYXJuOmF3czpzc286OjEyMzQ1Njc4OTAxMjphcHBsaWNhdGlvbi9zc29pbnMtMTExMTExMTExMTExL2FwbC0yMjIyMjIyMjIyMjIiLCJhd3M6aW5zdGFuY2VfYXJuIjoiYXJuOmF3czpzc286OjppbnN0YW5jZS9zc29pbnMtMTExMTExMTExMTExIiwiYXdzOmNyZWRlbnRpYWxfaWQiOiJfWlIyTjZhVkJqMjdGUEtheWpfcEtwVjc3QVBERl80MXB4ZXRfWWpJdUpONlVJR2RBdkpFWEFNUExFQ1JFRElEIiwiYXV0aF90aW1lIjoiMjAyMC0wMS0yMlQxMjo0NToyOVoiLCJleHAiOjE1Nzk3Mjk1MjksImlhdCI6MTU3OTcyNTkyOX0.5SYiW1kMsuUr7nna-l5tlakM0GNbMHvIM2_n0QD23jM',
    'issuedTokenType' => 'urn:ietf:params:oauth:token-type:access_token',
    'scope' => [
        'openid',
        'aws',
        'sts:identity_context',
    ],
    'tokenType' => 'Bearer',
]

RegisterClient

$result = $client->registerClient([/* ... */]);
$promise = $client->registerClientAsync([/* ... */]);

Registers a client with IAM Identity Center. This allows clients to initiate device authorization. The output should be persisted for reuse through many authentication requests.

Parameter Syntax

$result = $client->registerClient([
    'clientName' => '<string>', // REQUIRED
    'clientType' => '<string>', // REQUIRED
    'entitledApplicationArn' => '<string>',
    'grantTypes' => ['<string>', ...],
    'issuerUrl' => '<string>',
    'redirectUris' => ['<string>', ...],
    'scopes' => ['<string>', ...],
]);

Parameter Details

Members
clientName
Required: Yes
Type: string

The friendly name of the client.

clientType
Required: Yes
Type: string

The type of client. The service supports only public as a client type. Anything other than public will be rejected by the service.

entitledApplicationArn
Type: string

This IAM Identity Center application ARN is used to define administrator-managed configuration for public client access to resources. At authorization, the scopes, grants, and redirect URI available to this client will be restricted by this application resource.

grantTypes
Type: Array of strings

The list of OAuth 2.0 grant types that are defined by the client. This list is used to restrict the token granting flows available to the client.

issuerUrl
Type: string

The IAM Identity Center Issuer URL associated with an instance of IAM Identity Center. This value is needed for user access to resources through the client.

redirectUris
Type: Array of strings

The list of redirect URI that are defined by the client. At completion of authorization, this list is used to restrict what locations the user agent can be redirected back to.

scopes
Type: Array of strings

The list of scopes that are defined by the client. Upon authorization, this list is used to restrict permissions when granting an access token.

Result Syntax

[
    'authorizationEndpoint' => '<string>',
    'clientId' => '<string>',
    'clientIdIssuedAt' => <integer>,
    'clientSecret' => '<string>',
    'clientSecretExpiresAt' => <integer>,
    'tokenEndpoint' => '<string>',
]

Result Details

Members
authorizationEndpoint
Type: string

An endpoint that the client can use to request authorization.

clientId
Type: string

The unique identifier string for each client. This client uses this identifier to get authenticated by the service in subsequent calls.

clientIdIssuedAt
Type: long (int|float)

Indicates the time at which the clientId and clientSecret were issued.

clientSecret
Type: string

A secret string generated for the client. The client will use this string to get authenticated by the service in subsequent calls.

clientSecretExpiresAt
Type: long (int|float)

Indicates the time at which the clientId and clientSecret will become invalid.

tokenEndpoint
Type: string

An endpoint that the client can use to create tokens.

Errors

InvalidRequestException:

Indicates that something is wrong with the input to the request. For example, a required parameter might be missing or out of range.

InvalidScopeException:

Indicates that the scope provided in the request is invalid.

InvalidClientMetadataException:

Indicates that the client information sent in the request during registration is invalid.

InternalServerException:

Indicates that an error from the service occurred while trying to process a request.

InvalidRedirectUriException:

Indicates that one or more redirect URI in the request is not supported for this operation.

UnsupportedGrantTypeException:

Indicates that the grant type in the request is not supported by the service.

Examples

Example 1: Call OAuth/OIDC /register-client endpoint

$result = $client->registerClient([
    'clientName' => 'My IDE Plugin',
    'clientType' => 'public',
    'entitledApplicationArn' => 'arn:aws:sso::ACCOUNTID:application/ssoins-1111111111111111/apl-1111111111111111',
    'grantTypes' => [
        'authorization_code',
        'refresh_token',
    ],
    'issuerUrl' => 'https://identitycenter.amazonaws.com/ssoins-1111111111111111',
    'redirectUris' => [
        '127.0.0.1:PORT/oauth/callback',
    ],
    'scopes' => [
        'sso:account:access',
        'codewhisperer:completions',
    ],
]);

Result syntax:

[
    'clientId' => '_yzkThXVzLWVhc3QtMQEXAMPLECLIENTID',
    'clientIdIssuedAt' => 1579725929,
    'clientSecret' => 'VERYLONGSECRETeyJraWQiOiJrZXktMTU2NDAyODA5OSIsImFsZyI6IkhTMzg0In0',
    'clientSecretExpiresAt' => 1587584729,
]

StartDeviceAuthorization

$result = $client->startDeviceAuthorization([/* ... */]);
$promise = $client->startDeviceAuthorizationAsync([/* ... */]);

Initiates device authorization by requesting a pair of verification codes from the authorization service.

Parameter Syntax

$result = $client->startDeviceAuthorization([
    'clientId' => '<string>', // REQUIRED
    'clientSecret' => '<string>', // REQUIRED
    'startUrl' => '<string>', // REQUIRED
]);

Parameter Details

Members
clientId
Required: Yes
Type: string

The unique identifier string for the client that is registered with IAM Identity Center. This value should come from the persisted result of the RegisterClient API operation.

clientSecret
Required: Yes
Type: string

A secret string that is generated for the client. This value should come from the persisted result of the RegisterClient API operation.

startUrl
Required: Yes
Type: string

The URL for the Amazon Web Services access portal. For more information, see Using the Amazon Web Services access portal in the IAM Identity Center User Guide.

Result Syntax

[
    'deviceCode' => '<string>',
    'expiresIn' => <integer>,
    'interval' => <integer>,
    'userCode' => '<string>',
    'verificationUri' => '<string>',
    'verificationUriComplete' => '<string>',
]

Result Details

Members
deviceCode
Type: string

The short-lived code that is used by the device when polling for a session token.

expiresIn
Type: int

Indicates the number of seconds in which the verification code will become invalid.

interval
Type: int

Indicates the number of seconds the client must wait between attempts when polling for a session.

userCode
Type: string

A one-time user verification code. This is needed to authorize an in-use device.

verificationUri
Type: string

The URI of the verification page that takes the userCode to authorize the device.

verificationUriComplete
Type: string

An alternate URL that the client can use to automatically launch a browser. This process skips the manual step in which the user visits the verification page and enters their code.

Errors

InvalidRequestException:

Indicates that something is wrong with the input to the request. For example, a required parameter might be missing or out of range.

InvalidClientException:

Indicates that the clientId or clientSecret in the request is invalid. For example, this can occur when a client sends an incorrect clientId or an expired clientSecret.

UnauthorizedClientException:

Indicates that the client is not currently authorized to make the request. This can happen when a clientId is not issued for a public client.

SlowDownException:

Indicates that the client is making the request too frequently and is more than the service can handle.

InternalServerException:

Indicates that an error from the service occurred while trying to process a request.

Examples

Example 1: Call OAuth/OIDC /start-device-authorization endpoint

$result = $client->startDeviceAuthorization([
    'clientId' => '_yzkThXVzLWVhc3QtMQEXAMPLECLIENTID',
    'clientSecret' => 'VERYLONGSECRETeyJraWQiOiJrZXktMTU2NDAyODA5OSIsImFsZyI6IkhTMzg0In0',
    'startUrl' => 'https://identitycenter.amazonaws.com/ssoins-111111111111',
]);

Result syntax:

[
    'deviceCode' => 'yJraWQiOiJrZXktMTU2Njk2ODA4OCIsImFsZyI6IkhTMzIn0EXAMPLEDEVICECODE',
    'expiresIn' => 1579729529,
    'interval' => 1,
    'userCode' => 'makdfsk83yJraWQiOiJrZXktMTU2Njk2sImFsZyI6IkhTMzIn0EXAMPLEUSERCODE',
    'verificationUri' => 'https://device.sso.us-west-2.amazonaws.com',
    'verificationUriComplete' => 'https://device.sso.us-west-2.amazonaws.com?user_code=makdfsk83yJraWQiOiJrZXktMTU2Njk2sImFsZyI6IkhTMzIn0EXAMPLEUSERCODE',
]

Shapes

AccessDeniedException

Description

You do not have sufficient access to perform this action.

Members
error
Type: string

Single error code. For this exception the value will be access_denied.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

AuthorizationPendingException

Description

Indicates that a request to authorize a client with an access user session token is pending.

Members
error
Type: string

Single error code. For this exception the value will be authorization_pending.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

ExpiredTokenException

Description

Indicates that the token issued by the service is expired and is no longer valid.

Members
error
Type: string

Single error code. For this exception the value will be expired_token.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

InternalServerException

Description

Indicates that an error from the service occurred while trying to process a request.

Members
error
Type: string

Single error code. For this exception the value will be server_error.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

InvalidClientException

Description

Indicates that the clientId or clientSecret in the request is invalid. For example, this can occur when a client sends an incorrect clientId or an expired clientSecret.

Members
error
Type: string

Single error code. For this exception the value will be invalid_client.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

InvalidClientMetadataException

Description

Indicates that the client information sent in the request during registration is invalid.

Members
error
Type: string

Single error code. For this exception the value will be invalid_client_metadata.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

InvalidGrantException

Description

Indicates that a request contains an invalid grant. This can occur if a client makes a CreateToken request with an invalid grant type.

Members
error
Type: string

Single error code. For this exception the value will be invalid_grant.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

InvalidRedirectUriException

Description

Indicates that one or more redirect URI in the request is not supported for this operation.

Members
error
Type: string

Single error code. For this exception the value will be invalid_redirect_uri.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

InvalidRequestException

Description

Indicates that something is wrong with the input to the request. For example, a required parameter might be missing or out of range.

Members
error
Type: string

Single error code. For this exception the value will be invalid_request.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

InvalidRequestRegionException

Description

Indicates that a token provided as input to the request was issued by and is only usable by calling IAM Identity Center endpoints in another region.

Members
endpoint
Type: string

Indicates the IAM Identity Center endpoint which the requester may call with this token.

error
Type: string

Single error code. For this exception the value will be invalid_request.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

region
Type: string

Indicates the region which the requester may call with this token.

InvalidScopeException

Description

Indicates that the scope provided in the request is invalid.

Members
error
Type: string

Single error code. For this exception the value will be invalid_scope.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

SlowDownException

Description

Indicates that the client is making the request too frequently and is more than the service can handle.

Members
error
Type: string

Single error code. For this exception the value will be slow_down.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

UnauthorizedClientException

Description

Indicates that the client is not currently authorized to make the request. This can happen when a clientId is not issued for a public client.

Members
error
Type: string

Single error code. For this exception the value will be unauthorized_client.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.

UnsupportedGrantTypeException

Description

Indicates that the grant type in the request is not supported by the service.

Members
error
Type: string

Single error code. For this exception the value will be unsupported_grant_type.

error_description
Type: string

Human-readable text providing additional information, used to assist the client developer in understanding the error that occurred.