

# GetDelegatedAccessToken
<a name="API_GetDelegatedAccessToken"></a>

Exchanges a trade-in token for temporary Amazon credentials with the permissions associated with the assumed principal. This operation allows you to obtain credentials for a specific principal based on a trade-in token, enabling delegation of access to Amazon resources.

## Request Parameters
<a name="API_GetDelegatedAccessToken_RequestParameters"></a>

 For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

 ** TradeInToken **   
The token to exchange for temporary Amazon credentials. This token must be valid and unexpired at the time of the request.  
Type: String  
Required: Yes

## Response Elements
<a name="API_GetDelegatedAccessToken_ResponseElements"></a>

The following elements are returned by the service.

 ** AssumedPrincipal **   
The Amazon Resource Name (ARN) of the principal that was assumed when obtaining the delegated access token. This ARN identifies the IAM entity whose permissions are granted by the temporary credentials.  
Type: String  
Length Constraints: Minimum length of 20. Maximum length of 2048.  
Pattern: `[\u0009\u000A\u000D\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF]+` 

 ** Credentials **   
 Amazon credentials for API authentication.  
Type: [Credentials](API_Credentials.md) object

 ** PackedPolicySize **   
The percentage of the maximum policy size that is used by the session policy. The policy size is calculated as the sum of all the session policies and permission boundaries attached to the session. If the packed size exceeds 100%, the request fails.  
Type: Integer  
Valid Range: Minimum value of 0.

## Errors
<a name="API_GetDelegatedAccessToken_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** ExpiredTradeInToken **   
The trade-in token provided in the request has expired and can no longer be exchanged for credentials. Request a new token and retry the operation.  
HTTP Status Code: 400

 ** PackedPolicyTooLarge **   
The request was rejected because the total packed size of the session policies and session tags combined was too large. An Amazon conversion compresses the session policy document, session policy ARNs, and session tags into a packed binary format that has a separate limit. The error message indicates by percentage how close the policies and tags are to the upper size limit. For more information, see [Passing Session Tags in Amazon STS](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_session-tags.html) in the *IAM User Guide*.  
You could receive this error even though you meet other defined session policy and session tag limits. For more information, see [IAM and Amazon STS Entity Character Limits](https://docs.amazonaws.cn/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-limits-entity-length) in the *IAM User Guide*.  
HTTP Status Code: 400

## See Also
<a name="API_GetDelegatedAccessToken_SeeAlso"></a>

For more information about using this API in one of the language-specific Amazon SDKs, see the following:
+  [Amazon Command Line Interface V2](https://docs.amazonaws.cn/goto/cli2/sts-2011-06-15/GetDelegatedAccessToken) 
+  [Amazon SDK for .NET V4](https://docs.amazonaws.cn/goto/DotNetSDKV4/sts-2011-06-15/GetDelegatedAccessToken) 
+  [Amazon SDK for C\$1\$1](https://docs.amazonaws.cn/goto/SdkForCpp/sts-2011-06-15/GetDelegatedAccessToken) 
+  [Amazon SDK for Go v2](https://docs.amazonaws.cn/goto/SdkForGoV2/sts-2011-06-15/GetDelegatedAccessToken) 
+  [Amazon SDK for Java V2](https://docs.amazonaws.cn/goto/SdkForJavaV2/sts-2011-06-15/GetDelegatedAccessToken) 
+  [Amazon SDK for JavaScript V3](https://docs.amazonaws.cn/goto/SdkForJavaScriptV3/sts-2011-06-15/GetDelegatedAccessToken) 
+  [Amazon SDK for Kotlin](https://docs.amazonaws.cn/goto/SdkForKotlin/sts-2011-06-15/GetDelegatedAccessToken) 
+  [Amazon SDK for PHP V3](https://docs.amazonaws.cn/goto/SdkForPHPV3/sts-2011-06-15/GetDelegatedAccessToken) 
+  [Amazon SDK for Python](https://docs.amazonaws.cn/goto/boto3/sts-2011-06-15/GetDelegatedAccessToken) 
+  [Amazon SDK for Ruby V3](https://docs.amazonaws.cn/goto/SdkForRubyV3/sts-2011-06-15/GetDelegatedAccessToken) 