OpenAPITools / OpenAPITools/openapi-generator

How can I add AWS identity pool credentials to my API calls?

Open
#12,925 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Hello,

I am using the dart-dio-next generator on a Flutter project, and for the moment it's been working great. My aws API is protected by a user pool, so I add an Authorization header to all requests like so :

final response = await api.getShop(shopId: shopId, headers: {
  'Authorization': 'Bearer $TOKEN', // user pool token added here, works great
});

However, I now want to exchange my user pool token for Identity pool credentials, and use those instead to authenticate (as described here). The problem is that I'm not sure how to pass those to the request. Getting the credentials works fine, like so :

final credentials = CognitoCredentials('eu-west-3:5d943g9f-caa3-12bb-6fe1-92119691dc91', _userPool);

await credentials.getAwsCredentials(_session!.getIdToken().getJwtToken());
print(credentials.userIdentityId); // eu-west-3:b0eb9b78-a027-4882-9ef6-c37f7633b280

print(credentials.accessKeyId);
// ASIAZQBXPWO5M5YL6YNQ

print(credentials.secretAccessKey);
// Z48bwq2KC+ChzIGjzaFjUHJ29RkecLaVkd1Ms2yY

print(credentials.sessionToken);
// IQoJb3JpZ2luX2VjEM3//////////wEaCWV1LXdlc3QtMyJHMEUCIQCXnThKYvwIkOWSZNBtIjhoHgqD8X5vumajYQbQJxl1YQIgMUISwZPnw2Rs9BEdZV9FVTLptLTev/MGJgF1yvOybtIqxAQIFhAAGgw2NTI5NTE0MDE0MDIiDPc9FurSa18vXOlyqiqhBM9HCLL4Z3KNlo7icpMznpt5JM2b49GtODvJt9QKBJymDpw1Fiot0Rv7anRpvNorKqRA/NECvj/TxVyxyxdVoN+qvjVfXk8nAv/57gWc1EFgzfvS9WkdDfULAgtnaUzk3vaQl9ZMQ7yiB7z1ngeuJbS9b/lIBMtB8ZRDu5aQgoy5KwmmxZW6S8dtdy0RbRoh5t5EefdiNtVoxZFgmJg08DDUz1xyPVHLGsv+Oj+upYOoGdnN4Yfw3gpMLFP9J8ASD8mc80rUhsy9HAkdW7WYcOpPqHsArIsDbStAql+TTKmRiiYwfau37eXyBcc6WY0Gv5PGNtVVJHYEduRQj7JIMUf8qSVztxOyXbRGGtmC+a1crkmNHmK5iEhYhLYqt3zTGqZnUVICKEy+5Wzp1pzXAGqFfl+1fC6+AzJnDL10p7/6ZTS18/1N+za1D8PIJJtuKOkPPbGm9YupoP18K85ZLedZXo5v+RaNlAEjuNsfzkI433yJgL5ATVQBCZzdda3EsyWmpungupfNRYV7zYWlz0LACVfSfLcvGTzu8og0tqbdWHi54BrP9iHQfQTeDLvkNFqEeOHPK0Ri+QEzHkxILonPKtsC/J+ztCAeFb1a6/TFmUlk9z8j8aP1CgI8JevDQbAlncadE65JE2xZO+0xkHBqQUIjUmHAeWlPVsmD9I9zoHzgF8q9dZw8LOXxK4as4enqtTMZiwR9Bp7AqyZwrIICMKrT2pYGOoUC74IpwySISWglwXucBKQrkGF3Q6xCwOHXrLzAKOZSEqeDzksdGfNhnnb0/yCmpI06Xvl0ZxP5FX6Q6LRBy9xSdD+lO8r4aS6kFXs47yrcS3CqB8c9b+815tokgkj62gJ3wID9LrDBrEt4vsd4YbTn0+uh81QNO9n5c2X77pKLFazaHLLt2h/77RqcTtD9kgJEOXIUGWe8k0RelGbaJVgOhyScY6dsVq1sI+ZHGFskmenHvGwUeB1Wqwb6Qk7V47DOyhoeQV5j6BQnq1jRYZ97o98XgJsgDJgvphX7T+BqZM2JpfnP2njK2gQQykuCqZ0xEl+QbzMXIIeeavx36VeD/G3ISXDuac

As I said, auth with the user pool token works fine, but now I need to use an Identity Pool to retrieve correct IAM Role & permissions, and from my understanding I need to somehow use the accessKeyId, secretAccessKey and sessionToken that my identity pool is returning in my API calls.

Thanks in advance for any help!

Command line used for generation
npx @openapitools/openapi-generator-cli generate -i $open_api_file -g dart-dio-next -o dist/$sdk_name/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dart-dio-next generator and the generated API client, then compare the requested credential flow with the linked AWS Cognito authentication documentation. Determine whether credential injection requires a generator change or documentation; done means a clear, reproducible path for authenticated API calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, dart, flutter, openapi
Domain
api, authentication, authorization, mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.