aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
2.97k stars 556 forks source link

GetCredentialsForIdentityCommand response case problem #5997

Closed gemmerton closed 2 months ago

gemmerton commented 2 months ago

Checkboxes for prior research

Describe the bug

When using GetCredentialsForIdentityCommand the response returns AccessKeyId, SecretKey and SessionToken. However, other AWS services to which these credentials need to be passed are expecting the format accessKeyId, secretAccessKey and sessionToken.

So the response from the Cognito call needs to have the case changed in order to be useful for calls to other AWS services.

SDK version number

@aws-sdk/package-name@version, ...

Which JavaScript Runtime is this issue in?

Browser

Details of the browser/Node.js/ReactNative version

Chrome vers 123.0.6312.106

Reproduction Steps

Standard response from a GetCredentialsForIdentityCommand

Observed Behavior

As per description, response is incorrect case/format for use with other AWS services

Expected Behavior

response should contain accessKeyId, secretAccessKey and sessionToken

Possible Solution

No response

Additional Information/Context

No response

RanVaknin commented 2 months ago

Hi @gemmerton ,

If you didn't know, all of the AWS SDKs are code generated from the API models of the various AWS services. The types the SDK generates are matching whatever the AWS service specifies in their API model (PascalCase AccessKeyId). The service team cannot change the casing of the response they return since it would be considered a breaking change.

The solution here is to reconstruct the credential object yourself. something like this:

const credentials = {
        accessKeyId: cognitoResponse.Credentials.AccessKeyId,
        secretAccessKey: cognitoResponse.Credentials.SecretAccessKey,
        sessionToken: cognitoResponse.Credentials.SessionToken
 }

Thanks, Ran~

github-actions[bot] commented 2 months ago

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

github-actions[bot] commented 1 month ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.