Skip to content

Commit

Permalink
fix(Auth): Adding credentialsProvider to Cognito clients
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh62 committed Jun 10, 2024
1 parent 53d0fff commit 4c9cec5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation
@_spi(InternalAmplifyConfiguration) import Amplify

import AWSCognitoIdentity
import AWSCognitoIdentityProvider
import AWSPluginsCore
Expand Down Expand Up @@ -112,6 +111,8 @@ extension AWSCognitoAuthPlugin {
configuration.retryStrategyOptions = RetryStrategyOptions(maxRetriesBase: Int(maxRetryUnwrapped))
}

configuration.credentialsProvider = AmplifyAWSCredentialsProvider()

return CognitoIdentityProviderClient(config: configuration)
default:
fatalError()
Expand All @@ -134,6 +135,8 @@ extension AWSCognitoAuthPlugin {
configuration.retryStrategyOptions = RetryStrategyOptions(maxRetriesBase: Int(maxRetryUnwrapped))
}

configuration.credentialsProvider = AmplifyAWSCredentialsProvider()

return CognitoIdentityClient(config: configuration)
default:
fatalError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import Foundation

public class AmplifyAWSCredentialsProvider: AWSClientRuntime.CredentialsProviding {

public init() { }

public func getCredentials() async throws -> AWSClientRuntime.AWSCredentials {
let authSession = try await Amplify.Auth.fetchAuthSession()
if let awsCredentialsProvider = authSession as? AuthAWSCredentialsProvider {
Expand Down

0 comments on commit 4c9cec5

Please sign in to comment.