View a markdown version of this page

StartOAuthSession - AWS IAM CredentialBroker Data Plane

StartOAuthSession

Starts a consent session so an end user can authorize the broker to obtain tokens on their behalf. Returns a URL to send the user's browser to, and a handle identifying the session.

Call this when GetOAuthToken returns no token for a provider that requires user consent. When a valid token is already available, this returns it directly and no consent is needed.

The operation is not idempotent and takes no idempotency token: it is an OAuth consent-flow step rather than durable resource creation. A replayed session is rejected by CompleteOAuthSessionBinding with SESSION_STATE_CONFLICT.

Request Syntax

POST /StartOAuthSession HTTP/1.1 Content-type: application/json { "audiences": [ "string" ], "credentialProviderArn": "string", "customParameters": { "string" : "string" }, "customState": "string", "resources": [ "string" ], "scopes": [ "string" ], "sessionBindingUrl": "string" }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

audiences

Audience values (RFC 8693) naming the intended recipients of this token. Omit unless the authorization server requires them.

Type: Array of strings

Array Members: Minimum number of 0 items. Maximum number of 10 items.

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: No

credentialProviderArn

Amazon Resource Name of the credential provider the user is granting consent for.

Type: String

Pattern: arn:(aws|aws-us-gov|aws-cn|aws-iso|aws-iso-b|aws-iso-e|aws-iso-f|aws-eusc):credentialbroker:[a-z0-9-]{1,64}:[0-9]{12}:credentialproviderpool/[a-z0-9]{1,64}/credentialprovider/[a-z0-9]{1,64}

Required: Yes

customParameters

Extra parameters to include in the request to the authorization server, for vendor extensions. Added to the standard OAuth parameters; they never override them.

Type: String to string map

Map Entries: Minimum number of 0 items. Maximum number of 20 items.

Key Length Constraints: Minimum length of 1. Maximum length of 256.

Key Pattern: [a-zA-Z0-9_.-]+

Value Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: No

customState

An opaque string of your own that is sent back to your session-binding URL unchanged. Use it to tie the response to the request you issued, so your handler can reject a response it did not initiate.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: No

resources

Resource indicators (RFC 8707) naming the APIs this token is for. Omit unless the authorization server requires them.

Type: Array of strings

Array Members: Minimum number of 0 items. Maximum number of 10 items.

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: No

scopes

The OAuth scopes to request from the authorization server.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 20 items.

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: No

sessionBindingUrl

The URL the end user's browser is returned to once they have responded to the consent prompt. Must match one of the session-binding URLs allowed on the provider.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: https?://(\[[0-9A-Fa-f:]+\]|[^\s:/?#\[\]]+)(:[0-9]+)?(/[^\s]*)?

Required: Yes

Response Syntax

HTTP/1.1 200 Content-type: application/json { "accessToken": "string", "authorizationUrl": "string", "expiresAt": number, "sessionStatus": "string", "sessionUri": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

accessToken

Present only when a valid token already existed (no consent needed).

Type: String

Length Constraints: Minimum length of 1. Maximum length of 131072.

authorizationUrl

The URL to send the end user's browser to so they can grant consent. Present only when consent is required; absent when a token was available and is returned instead.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 8192.

Pattern: https://[^\s]+

expiresAt

Expiry of accessToken when returned.

Type: Timestamp

sessionStatus

Status of the session (IN_PROGRESS when consent is required).

Type: String

Valid Values: IN_PROGRESS | COMPLETED | FAILED

sessionUri

Opaque handle to the pending consent session. Present only when interactive consent is required (absent when accessToken is returned).

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: urn:ietf:params:oauth:request_uri:[a-zA-Z0-9-._~]+

Errors

For information about the errors that are common to all actions, see Common Error Types.

AccessDeniedException

The caller is not authorized to perform the request, or a resource the request depends on refused access. reason distinguishes a denial by this service from a denial reported by a dependency the caller configured, such as a customer-owned secret, KMS key, or external identity provider, which usually points at a permission or configuration fix outside this API.

HTTP Status Code: 403

InternalServerException

The request failed because of an unexpected error in the service. Whether the request took effect is undefined, so for a create or update, read the resource back before retrying. Retryable: the same request may succeed later.

retryAfterSeconds

The number of seconds to wait before retrying. If this field is absent, retry with exponential backoff.

HTTP Status Code: 500

ResourceNotFoundException

The requested resource does not exist, or the caller is not permitted to know that it exists. A resource that was deleted, or that is still being created, can also be reported this way.

resourceId

The identifier of the resource that could not be found, echoed from the request.

resourceType

The type of the resource named by resourceId, when present.

HTTP Status Code: 404

ServiceUnavailableException

A downstream dependency the broker relies on is temporarily unavailable, notably the customer's external IdP token/discovery endpoint (upstream 5xx, server_error, or temporarily_unavailable). Retryable: the same request may succeed later.

retryAfterSeconds

The number of seconds to wait before retrying. If this field is absent, retry with exponential backoff.

HTTP Status Code: 503

ThrottlingException

The request was denied because the caller exceeded a request rate limit. Nothing was changed. Retry with exponential backoff, honoring retryAfterSeconds when it is present.

retryAfterSeconds

The number of seconds to wait before retrying. If this field is absent, retry with exponential backoff.

HTTP Status Code: 429

ValidationException

The request is not valid. The request was rejected before any change was made, so it is safe to correct the input and retry. Use reason to branch in code and message for the human-readable detail of which field or combination of fields was at fault.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: