Skip to content

UserPoolCredentialProvider - How to access tokens #27

Answered by adam-fowler
bmdragos asked this question in Q&A
Discussion options

You must be logged in to vote

The UserPoolCredentialProvider is used for providing AWS credentials via User Pools. It isn't really designed for providing access to the access, id and refresh tokens. Here would be an example usage where I use it to access an object stored on S3.

let credentialProvider: CredentialProviderFactory = .cognitoUserPool(
    userName: myName,
    authentication: .password(myPassword),
    ...
)
let client = AWSClient(credentialProvider: credentialProvider, httpClientProvider: .createNew)
let s3 = S3(client: client, region: .euwest1)
let data = try await s3.getObject(.init(bucket: myBucket, key: myKey))

If you want access, id or refresh tokens then you should use CognitoAuthenticatable

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bmdragos
Comment options

Answer selected by bmdragos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants