Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SignInWithAppleButton bug #3124

Closed
howardkitto opened this issue Aug 4, 2023 · 19 comments
Closed

SignInWithAppleButton bug #3124

howardkitto opened this issue Aug 4, 2023 · 19 comments
Assignees
Labels
auth Issues related to the Auth category question General question

Comments

@howardkitto
Copy link

howardkitto commented Aug 4, 2023

Describe the bug

I am following these instructions:

https://aws.amazon.com/blogs/mobile/federating-users-using-sign-in-with-apple-and-aws-amplify-for-swift/

Federation fails and the output doesn't help me to debug

Steps To Reproduce

Steps to reproduce the behavior:
1. Setup Amplify like this... https://docs.amplify.aws/lib/auth/social/q/platform/ios/
2. Set up swift code like this... https://aws.amazon.com/blogs/mobile/federating-users-using-sign-in-with-apple-and-aws-amplify-for-swift/
3. Run app from xcode simulator
4. Try to login with apple credentials

Expected behavior

I would expect to see the xcode console message "Successfully federated user to identity pool with result: ###"

Amplify Framework Version

12.2.3

Amplify Categories

Auth

Dependency manager

Swift PM

Swift version

4

CLI version

12.2.3

Xcode version

14.3.1

Relevant log output

<details>
<summary>Log Messages</summary>


Successfully configured Amplify
2023-08-04 15:00:34.819094+0100 Peakflow[4756:104392] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthConfiguration.swift Starting execution
2023-08-04 15:00:34.819175+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuth" =     {
    };
}
2023-08-04 15:00:34.820257+0100 Peakflow[4756:104392] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/MigrateLegacyCredentialStore.swift Starting execution
2023-08-04 15:00:34.821534+0100 Peakflow[4756:104390] [AWSCognitoAuthPlugin] Credential Store state change:

migratingLegacyStore
2023-08-04 15:00:34.859901+0100 Peakflow[4756:104392] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/MigrateLegacyCredentialStore.swift Sending event CredentialStoreEvent.loadCredentialStore
2023-08-04 15:00:34.860040+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Credential Store state change:

loadingStoredCredentials
2023-08-04 15:00:34.860102+0100 Peakflow[4756:104393] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/LoadCredentialStore.swift Starting execution
2023-08-04 15:00:34.861079+0100 Peakflow[4756:104393] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/LoadCredentialStore.swift Retreiving credential amplifyCredentials
2023-08-04 15:00:34.864344+0100 Peakflow[4756:104393] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/LoadCredentialStore.swift Sending event CredentialStoreEvent.throwError
2023-08-04 15:00:34.864463+0100 Peakflow[4756:104393] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/IdleCredentialStore.swift Starting execution
2023-08-04 15:00:34.864480+0100 Peakflow[4756:104392] [AWSCognitoAuthPlugin] No existing session found.
2023-08-04 15:00:34.864539+0100 Peakflow[4756:104393] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/IdleCredentialStore.swift Sending event CredentialStoreEvent.moveToIdleState
2023-08-04 15:00:34.864659+0100 Peakflow[4756:104392] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthConfiguration.swift Sending event AuthEvent.validateCredentialAndConfiguration
2023-08-04 15:00:34.864840+0100 Peakflow[4756:104397] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ValidateCredentialsAndConfiguration.swift Starting execution
2023-08-04 15:00:34.864872+0100 Peakflow[4756:104390] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.validatingCredentialsAndConfiguration" =     {
    };
}
2023-08-04 15:00:34.864943+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Credential Store state change:

error(KeychainStoreError: Unable to find the keychain item
Recovery suggestion: This should not happen. There is a possibility that there is a bug if this error persists. Please take a look at https://github.com/aws-amplify/amplify-ios/issues to see if there are any existing issues that match your scenario, and file an issue with the details of the bug if there isn't. Issue encountered at:
file: /####/SourcePackages/checkouts/amplify-swift/AmplifyPlugins/Core/AWSPluginsCore/Keychain/KeychainStoreError.swift
function: recoverySuggestion
line: 69)
2023-08-04 15:00:34.864948+0100 Peakflow[4756:104397] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ValidateCredentialsAndConfiguration.swift Sending event AuthEvent.configureAuthentication
2023-08-04 15:00:34.865019+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Credential Store state change:

idle
2023-08-04 15:00:34.865539+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthentication" =     {
        "AuthenticationState.notConfigured" =         {
        };
    };
}
2023-08-04 15:00:34.865778+0100 Peakflow[4756:104397] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthenticationConfiguration.swift Starting execution
2023-08-04 15:00:34.865861+0100 Peakflow[4756:104397] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthenticationConfiguration.swift Sending event AuthenticationEvent.configure
2023-08-04 15:00:34.866889+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthentication" =     {
        "AuthenticationState.configured" =         {
        };
    };
}
2023-08-04 15:00:34.866915+0100 Peakflow[4756:104390] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthentication.swift Start execution
2023-08-04 15:00:34.867270+0100 Peakflow[4756:104390] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthentication.swift Sending event AuthenticationEvent.initializedSignedOut
2023-08-04 15:00:34.867460+0100 Peakflow[4756:104390] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthentication.swift Sending event AuthEvent.authenticationConfigured
2023-08-04 15:00:34.867550+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthentication" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
    };
}
2023-08-04 15:00:34.867792+0100 Peakflow[4756:104390] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthorizationConfiguration.swift Starting execution
2023-08-04 15:00:34.867971+0100 Peakflow[4756:104390] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthorizationConfiguration.swift Sending event AuthorizationEvent.configure
2023-08-04 15:00:34.867978+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthorization" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.notConfigured" =         {
        };
    };
}
2023-08-04 15:00:34.870767+0100 Peakflow[4756:104390] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthorization.swift Starting execution
2023-08-04 15:00:34.870849+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthorization" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.configured" =         {
        };
    };
}
2023-08-04 15:00:34.870870+0100 Peakflow[4756:104390] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthorization.swift Sending event AuthEvent.authorizationConfigured
2023-08-04 15:00:34.871003+0100 Peakflow[4756:104391] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.configured" =         {
        };
    };
}
Token string #### //obfuscated for security
2023-08-04 15:13:33.610042+0100 Peakflow[4756:115897] [AWSAuthFederateToIdentityPoolTask] Starting execution
2023-08-04 15:13:33.610864+0100 Peakflow[4756:115897] [AWSAuthTaskHelper] Check if authstate configured
2023-08-04 15:13:33.611002+0100 Peakflow[4756:115897] [AWSAuthTaskHelper] Auth state configured
2023-08-04 15:13:33.612954+0100 Peakflow[4756:115897] [AWSAuthFederateToIdentityPoolTask] Waiting for federation to complete
2023-08-04 15:13:33.613052+0100 Peakflow[4756:116347] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.notStarted" =             {
            };
        };
    };
}
2023-08-04 15:13:33.613318+0100 Peakflow[4756:116348] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeFederationToIdentityPool.swift Starting execution
2023-08-04 15:13:33.613398+0100 Peakflow[4756:116348] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeFederationToIdentityPool.swift Sending event FetchAuthSessionEvent.fetchAuthenticatedIdentityID
2023-08-04 15:13:33.615995+0100 Peakflow[4756:116348] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Starting execution
2023-08-04 15:13:33.616064+0100 Peakflow[4756:116347] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.fetchingIdentityID" =             {
            };
        };
    };
}
2023-08-04T15:13:33+0100 info CognitoIdentityClient : [Logging] Request: POST https:443 
 Path: / 
 User-Agent: aws-sdk-swift/1.0 api/cognito-identity/1.0 os/iOS/16.4.0 lang/swift/5.8 lib/amplify-swift/2.11.4, 
Host: cognito-identity.eu-west-2.amazonaws.com, 
Content-Length: 884, 
x-amz-user-agent: aws-sdk-swift/1.0, 
Content-Type: application/x-amz-json-1.1, 
X-Amz-Target: AWSCognitoIdentityService.GetId 
 Optional([])
2023-08-04T15:13:33+0100 info SerialExecutor : [Logging] Creating connection pool for Optional("https://cognito-identity.eu-west-2.amazonaws.com/?")with max connections: 50
2023-08-04T15:13:33+0100 info CRTClientEngine : [Logging] Connection was acquired to: Optional("https://cognito-identity.eu-west-2.amazonaws.com/?")
2023-08-04 15:13:34.201501+0100 Peakflow[4756:116349] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Sending event FetchAuthSessionEvent.throwError
2023-08-04 15:13:34.201744+0100 Peakflow[4756:116348] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InformSessionError.swift Starting execution
2023-08-04 15:13:34.201835+0100 Peakflow[4756:116348] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InformSessionError.swift Sending event AuthorizationEvent.receivedSessionError
2023-08-04 15:13:34.203491+0100 Peakflow[4756:116347] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.error" =             {
                error = "AWSCognitoAuthPlugin.FetchSessionError.notAuthorized";
            };
        };
    };
}
Failed to federate to identity pool with error: AuthError: Not authorized error
Recovery suggestion: Check whether the given values are correct and the user is authorized to perform the operation.
2023-08-04 15:13:34.208379+0100 Peakflow[4756:116347] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthenticationError.service(message: \"Session error: notAuthorized\")";
        };
        "AuthorizationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthorizationError.sessionError(AWSCognitoAuthPlugin.FetchSessionError.notAuthorized, noCredentials)";
        };
    };
}
```

Is this a regression?

No

Regression additional context

No response

Platforms

iOS

OS Version

16.4

Device

iphone 14

Specific to simulators

No response

Additional context

here is my source code:

import SwiftUI
import Amplify
import AWSCognitoAuthPlugin

@main
struct MyApp: App {
    
    func configureAmplify() {
        do {
            try Amplify.add(plugin: AWSCognitoAuthPlugin())
            try Amplify.configure()
            Amplify.Logging.logLevel = .verbose
            print("Successfully configured Amplify")
        } catch {
            print("Failed to initialize Amplify:", error)
        }
    }
    
    init() {
        configureAmplify()
    }
    
    var body: some Scene {
        WindowGroup {
            SIWA()            
        }
    }
}

Content view

import SwiftUI
import AuthenticationServices
import Amplify
import AWSCognitoAuthPlugin

struct SIWA: View {
    
    func configureRequest(_ request: ASAuthorizationAppleIDRequest) {
        request.requestedScopes = [.email]
    }

    func handleResult(_ result: Result<ASAuthorization, Error>) {
        switch result {
        case .success(let authorization):
            guard
                let credential = authorization.credential as? ASAuthorizationAppleIDCredential,
                let identityToken = credential.identityToken
                    
            else { return }
            self.federateToIdentityPools(with: identityToken)            
        case .failure(let error):
            print("Line 29", error)
        }
    }
    
    func federateToIdentityPools(with token: Data) {
        guard
            let tokenString = String(data: token, encoding: .utf8),
            let plugin = try? Amplify.Auth.getPlugin(for: "awsCognitoAuthPlugin") as? AWSCognitoAuthPlugin
        else { return }
        
        print("Token string", tokenString)
        
        Task {
            do {
                let result = try await plugin.federateToIdentityPool(
                    withProviderToken: tokenString,
                    for: .apple
                )
                print("Successfully federated user to identity pool with result:", result)
            } catch {
                print("Failed to federate to identity pool with error:", error)
            }
        }
    }
    
    var body: some View {
        Text("Integrate Signin With Apple and AWS Cognito")
        SignInWithAppleButton(
            onRequest: configureRequest,
            onCompletion: handleResult
        )
        .frame(maxWidth: 300, maxHeight: 45)
    }
}

struct SIWA_Previews: PreviewProvider {
    static var previews: some View {
        SIWA()
    }
}

amplifyconfiguration.json

{
    "UserAgent": "aws-amplify-cli/2.0",
    "Version": "1.0",
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "UserAgent": "aws-amplify/cli",
                "Version": "0.1.0",
                "IdentityManager": {
                    "Default": {}
                },
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "eu-west-2:###",
                            "Region": "eu-west-2"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "eu-west-2####,
                        "AppClientId": "####",
                        "Region": "eu-west-2"
                    }
                },
                "Auth": {
                    "Default": {
                        "OAuth": {
                            "WebDomain": "####auth.eu-west-2.amazoncognito.com",
                            "AppClientId": "####",
                            "SignInRedirectURI": "myapp://",
                            "SignOutRedirectURI": "myapp://",
                            "Scopes": [
                                "phone",
                                "email",
                                "openid",
                                "profile",
                                "aws.cognito.signin.user.admin"
                            ]
                        },
                        "authenticationFlowType": "USER_SRP_AUTH",
                        "socialProviders": [
                            "APPLE"
                        ],
                        "usernameAttributes": [
                            "EMAIL"
                        ],
                        "signupAttributes": [
                            "EMAIL"
                        ],
                        "passwordProtectionSettings": {
                            "passwordPolicyMinLength": 8,
                            "passwordPolicyCharacters": []
                        },
                        "mfaConfiguration": "OFF",
                        "mfaTypes": [
                            "SMS"
                        ],
                        "verificationMechanisms": [
                            "EMAIL"
                        ]
                    }
                }
            }
        }
    }
}
@harsh62 harsh62 added the auth Issues related to the Auth category label Aug 4, 2023
@harsh62
Copy link
Member

harsh62 commented Aug 4, 2023

@howardkitto Thanks for raising the issue. Would you be able to share the details about how you are passing the token to federateToIdentityPools(with token: Data)?

@howardkitto
Copy link
Author

Thanks so much for such a quick response!

Yes, so, the SignInWithApple component calls a completion handler "handleResult()"

 SignInWithAppleButton(
            onRequest: configureRequest,
            onCompletion: handleResult
        )

handleResult creates an identityToken...

    func handleResult(_ result: Result<ASAuthorization, Error>) {
       switch result {
       case .success(let authorization):
           guard
               let credential = authorization.credential as? ASAuthorizationAppleIDCredential,
               let identityToken = credential.identityToken
                   
           else { return }
           self.federateToIdentityPools(with: identityToken)            <<<<<Here
       case .failure(let error):

       }
   }
   ```
this is passed as data to federateToIdentityPools. Does that answer the question? (The full code is in my bug ticket)

@harsh62
Copy link
Member

harsh62 commented Aug 4, 2023

@howardkitto Thanks for the information. It seems like Cognito is rejecting your identityToken. Would you be able to check if everything was setup correctly in Cognito?
That is just follow the setup part of the documentation.

Reference configuration screen.

image

@howardkitto
Copy link
Author

howardkitto commented Aug 4, 2023

@harsh62

I uploaded the p8 file again and here is the output....

Successfully configured Amplify
2023-08-04 17:16:37.093398+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/MigrateLegacyCredentialStore.swift Starting execution
2023-08-04 17:16:37.132974+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/MigrateLegacyCredentialStore.swift Sending event CredentialStoreEvent.loadCredentialStore
2023-08-04 17:16:37.133325+0100 Peakflow[7554:185528] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/LoadCredentialStore.swift Starting execution
2023-08-04 17:16:37.134648+0100 Peakflow[7554:185534] [AWSCognitoAuthPlugin] Credential Store state change:

loadingStoredCredentials
2023-08-04 17:16:37.134651+0100 Peakflow[7554:185528] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/LoadCredentialStore.swift Retreiving credential amplifyCredentials
2023-08-04 17:16:37.139793+0100 Peakflow[7554:185528] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/LoadCredentialStore.swift Sending event CredentialStoreEvent.throwError
2023-08-04 17:16:37.139995+0100 Peakflow[7554:185534] [AWSCognitoAuthPlugin] No existing session found.
2023-08-04 17:16:37.140011+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/IdleCredentialStore.swift Starting execution
2023-08-04 17:16:37.140137+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/IdleCredentialStore.swift Sending event CredentialStoreEvent.moveToIdleState
2023-08-04 17:16:37.140189+0100 Peakflow[7554:185534] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthConfiguration.swift Sending event AuthEvent.validateCredentialAndConfiguration
2023-08-04 17:16:37.140409+0100 Peakflow[7554:185528] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ValidateCredentialsAndConfiguration.swift Starting execution
2023-08-04 17:16:37.140509+0100 Peakflow[7554:185528] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ValidateCredentialsAndConfiguration.swift Sending event AuthEvent.configureAuthentication
2023-08-04 17:16:37.140528+0100 Peakflow[7554:185521] [AWSCognitoAuthPlugin] Credential Store state change:

error(KeychainStoreError: Unable to find the keychain item
Recovery suggestion: This should not happen. There is a possibility that there is a bug if this error persists. Please take a look at https://github.com/aws-amplify/amplify-ios/issues to see if there are any existing issues that match your scenario, and file an issue with the details of the bug if there isn't. Issue encountered at:
file: /Users/howardkitto/Library/Developer/Xcode/DerivedData/Peakflow-czxaxbppfxqirwbexnagrcpuqrbp/SourcePackages/checkouts/amplify-swift/AmplifyPlugins/Core/AWSPluginsCore/Keychain/KeychainStoreError.swift
function: recoverySuggestion
line: 69)
2023-08-04 17:16:37.140673+0100 Peakflow[7554:185521] [AWSCognitoAuthPlugin] Credential Store state change:

idle
2023-08-04 17:16:37.140731+0100 Peakflow[7554:185534] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthenticationConfiguration.swift Starting execution
2023-08-04 17:16:37.140843+0100 Peakflow[7554:185534] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthenticationConfiguration.swift Sending event AuthenticationEvent.configure
2023-08-04 17:16:37.141129+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.validatingCredentialsAndConfiguration" =     {
    };
}
2023-08-04 17:16:37.141305+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthentication" =     {
        "AuthenticationState.notConfigured" =         {
        };
    };
}
2023-08-04 17:16:37.141338+0100 Peakflow[7554:185534] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthentication.swift Start execution
2023-08-04 17:16:37.141427+0100 Peakflow[7554:185534] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthentication.swift Sending event AuthenticationEvent.initializedSignedOut
2023-08-04 17:16:37.141430+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthentication" =     {
        "AuthenticationState.configured" =         {
        };
    };
}
2023-08-04 17:16:37.141591+0100 Peakflow[7554:185534] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthentication.swift Sending event AuthEvent.authenticationConfigured
2023-08-04 17:16:37.141651+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthentication" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
    };
}
2023-08-04 17:16:37.141789+0100 Peakflow[7554:185535] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthorizationConfiguration.swift Starting execution
2023-08-04 17:16:37.141843+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthorization" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.notConfigured" =         {
        };
    };
}
2023-08-04 17:16:37.141891+0100 Peakflow[7554:185535] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeAuthorizationConfiguration.swift Sending event AuthorizationEvent.configure
2023-08-04 17:16:37.142659+0100 Peakflow[7554:185521] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthorization.swift Starting execution
2023-08-04 17:16:37.142714+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configuringAuthorization" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.configured" =         {
        };
    };
}
2023-08-04 17:16:37.142812+0100 Peakflow[7554:185521] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/ConfigureAuthorization.swift Sending event AuthEvent.authorizationConfigured
2023-08-04 17:16:37.143000+0100 Peakflow[7554:185527] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.signedOut" =         {
            lastKnownUserName = "(nil)";
        };
        "AuthorizationState.configured" =         {
        };
    };
}
Token string eyJraWQiOiJZdXlYb1kiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiYXVkIjoiaW5kdXN0cmllcy5pbnRlbnRpb25hbC5wZWFrZmxvdyIsImV4cCI6MTY5MTI1MjIxMCwiaWF0IjoxNjkxMTY1ODEwLCJzdWIiOiIwMDE5NjIuNjUyNjZiYTk0OWM4NDZkNThhODJiOTE5N2MwM2I5MzguMDkwNCIsImNfaGFzaCI6IldYSE9DODRCaXNtMFZNenFQMkZiT1EiLCJlbWFpbCI6ImtpdHRvLmhvd2FyZEBnbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6InRydWUiLCJhdXRoX3RpbWUiOjE2OTExNjU4MTAsIm5vbmNlX3N1cHBvcnRlZCI6dHJ1ZX0.JI5-8o6-j_eN5L2Ao2zOqIq31BkcRC813keCxxktTvHsLBAu1VYU29QRwUlLDHKW_Ym6yJw6w0Js3EMSWs6A-b3eyIKCufBkWs8W_At1hKcokTRV4xM2PvUX8pVuOgDCMt8ovkMRnf-CVy5sSbIxFMrGOa1yb3QS-4_GQ3E3F217GpFlIBUsLP9nd-cVLmZUa043hCcnlC1kRu4jGrQaP1grOMWDPH3cfGbgD23BxLe0iWw4a_RxLhlCO0J8ySsI_UaWhDaaxrwa5YEmEGTt9kERlc5YfoI7UvGIpX8L-igGxie75BakK--kXFW-sgq5KytH5PBMBf_81AoDT_iW3g
2023-08-04 17:16:50.631507+0100 Peakflow[7554:185527] [AWSAuthFederateToIdentityPoolTask] Starting execution
2023-08-04 17:16:50.632699+0100 Peakflow[7554:185527] [AWSAuthTaskHelper] Check if authstate configured
2023-08-04 17:16:50.632883+0100 Peakflow[7554:185527] [AWSAuthTaskHelper] Auth state configured
2023-08-04 17:16:50.633131+0100 Peakflow[7554:185527] [AWSAuthFederateToIdentityPoolTask] Waiting for federation to complete
2023-08-04 17:16:50.633287+0100 Peakflow[7554:185824] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeFederationToIdentityPool.swift Starting execution
2023-08-04 17:16:50.633327+0100 Peakflow[7554:185529] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.notStarted" =             {
            };
        };
    };
}
2023-08-04 17:16:50.633405+0100 Peakflow[7554:185824] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeFederationToIdentityPool.swift Sending event FetchAuthSessionEvent.fetchAuthenticatedIdentityID
2023-08-04 17:16:50.636553+0100 Peakflow[7554:185824] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Starting execution
2023-08-04 17:16:50.636634+0100 Peakflow[7554:185529] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.fetchingIdentityID" =             {
            };
        };
    };
}
2023-08-04T17:16:50+0100 info CognitoIdentityClient : [Logging] Request: POST https:443 
 Path: / 
 X-Amz-Target: AWSCognitoIdentityService.GetId, 
x-amz-user-agent: aws-sdk-swift/1.0, 
Content-Length: 884, 
User-Agent: aws-sdk-swift/1.0 api/cognito-identity/1.0 os/iOS/16.4.0 lang/swift/5.8 lib/amplify-swift/2.11.4, 
Content-Type: application/x-amz-json-1.1, 
Host: cognito-identity.eu-west-2.amazonaws.com 
 Optional([])
2023-08-04T17:16:50+0100 info SerialExecutor : [Logging] Creating connection pool for Optional("https://cognito-identity.eu-west-2.amazonaws.com/?")with max connections: 50
2023-08-04T17:16:50+0100 info CRTClientEngine : [Logging] Connection was acquired to: Optional("https://cognito-identity.eu-west-2.amazonaws.com/?")
2023-08-04 17:16:51.585389+0100 Peakflow[7554:185824] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Sending event FetchAuthSessionEvent.throwError
2023-08-04 17:16:51.585748+0100 Peakflow[7554:185825] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InformSessionError.swift Starting execution
2023-08-04 17:16:51.585883+0100 Peakflow[7554:185825] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InformSessionError.swift Sending event AuthorizationEvent.receivedSessionError
2023-08-04 17:16:51.587711+0100 Peakflow[7554:185529] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.error" =             {
                error = "AWSCognitoAuthPlugin.FetchSessionError.notAuthorized";
            };
        };
    };
}
Failed to federate to identity pool with error: AuthError: Not authorized error
Recovery suggestion: Check whether the given values are correct and the user is authorized to perform the operation.
2023-08-04 17:16:51.593149+0100 Peakflow[7554:185529] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthenticationError.service(message: \"Session error: notAuthorized\")";
        };
        "AuthorizationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthorizationError.sessionError(AWSCognitoAuthPlugin.FetchSessionError.notAuthorized, noCredentials)";
        };
    };
}

@harsh62
Copy link
Member

harsh62 commented Aug 4, 2023

@howardkitto
Thanks for all the information. I will try to repro this issue locally and get back to you as soon as we have more information.

@harsh62 harsh62 self-assigned this Aug 4, 2023
@harsh62 harsh62 added the bug Something isn't working label Aug 4, 2023
@adam-a
Copy link

adam-a commented Aug 6, 2023

Hi! Experiencing this as well -- also confident of my setup on the Apple + Cognito side.

Failed to federate to identity pool with error: The operation couldn’t be completed. (Amplify.AuthError error 4.)
2023-08-05 22:57:26.676834-0700 Waller[15593:1424041] [AuthenticationAWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthenticationError.service(message: \"Session error: notAuthorized\")";
        };
        "AuthorizationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthorizationError.sessionError(AWSCognitoAuthPlugin.FetchSessionError.notAuthorized, noCredentials)";
        };
    };
}

@harsh62
Copy link
Member

harsh62 commented Aug 9, 2023

@howardkitto @adam-a

To add a Sign in with Apple identity provider (IdP)

  1. Choose Identity pools from the Amazon Cognito console. Select an identity pool.
  2. Choose the User access tab.
  3. Select Add identity provider.
  4. Choose Sign in with Apple.
  5. Enter your bundle identifier for the app as the Services ID.
  6. Provide a role. You can assign users from that IdP the Default role that you set up when you configured your Authenticated role, or you can Choose role with rules.
  7. To change the principal tags that Amazon Cognito assigns when it issues credentials to users who have authenticated with this provider, configure Attributes for access control.
    a. To apply no principal tags, choose Inactive.
    b. To apply principal tags based on sub and aud claims, choose Use default mappings.
    c. To create your own custom schema of attributes to principal tags, choose Use custom mappings. Then enter a Tag key that you want to source from each Claim that you want to represent in a tag.
  8. Click save.

You should be good to go.

If it still doesn't work, could you please provide a screenshot of the identity pool provider, similar to what I am adding in this comment

image

@harsh62 harsh62 added pending-community-response Issue is pending response from the issue requestor question General question and removed bug Something isn't working labels Aug 9, 2023
@adam-a
Copy link

adam-a commented Aug 9, 2023

Hmm, so I do see a difference, but now I'm getting the output below. Here are my settings.

Screenshot 2023-08-08 at 10 06 40 PM

Screenshot 2023-08-08 at 10 05 50 PM

2023-08-08T21:59:07-0700 info SerialExecutor : [Logging] Creating connection pool for Optional("https://cognito-identity.us-east-1.amazonaws.com/?")with max connections: 50
2023-08-08T21:59:07-0700 info CRTClientEngine : [Logging] Connection was acquired to: Optional("https://cognito-identity.us-east-1.amazonaws.com/?")
2023-08-08 21:59:07.708029-0700 Wallr[32775:2926340] [AuthenticationAWSCognitoAuthPlugin] AWSCognitoAuthPlugin/FetchAuthAWSCredentials.swift Sending event FetchAuthSessionEvent.throwError
2023-08-08 21:59:07.708804-0700 Wallr[32775:2927648] [AuthenticationAWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InformSessionError.swift Starting execution
2023-08-08 21:59:07.708936-0700 Wallr[32775:2927648] [AuthenticationAWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InformSessionError.swift Sending event AuthorizationEvent.receivedSessionError
2023-08-08 21:59:07.710034-0700 Wallr[32775:2925667] [AuthenticationAWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.error" =             {
                error = "AWSCognitoAuthPlugin.FetchSessionError.service(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.client(ClientRuntime.ClientError.retryError(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.service(AWSCognitoIdentity.GetCredentialsForIdentityOutputError.invalidIdentityPoolConfigurationException(AWSCognitoIdentity.InvalidIdentityPoolConfigurationException(_headers: Optional(Content-Length: 143, \nConnection: keep-alive, \nStrict-Transport-Security: max-age=31536000; includeSubDomains, \nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:, \nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool., \nDate: Wed, 09 Aug 2023 04:59:07 GMT, \nContent-Type: application/x-amz-json-1.1, \nx-amzn-RequestId: 30935a6f-8195-438e-8bfe-93e5ff98322c), _statusCode: Optional(http_status_400), _message: Optional(\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\"), _requestID: Optional(\"30935a6f-8195-438e-8bfe-93e5ff98322c\"), _retryable: false, _isThrottling: false, _type: ClientRuntime.ErrorType.client, message: Optional(\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\"))), \nStatus Code: http_status_400 \n Content-Length: 143, \nConnection: keep-alive, \nStrict-Transport-Security: max-age=31536000; includeSubDomains, \nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:, \nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool., \nDate: Wed, 09 Aug 2023 04:59:07 GMT, \nContent-Type: application/x-amz-json-1.1, \nx-amzn-RequestId: 30935a6f-8195-438e-8bfe-93e5ff98322c)), nil))";
            };
        };
    };
}
Failed to federate to identity pool with error: The operation couldn’t be completed. (Amplify.AuthError error 0.)
2023-08-08 21:59:07.712348-0700 Wallr[32775:2925667] [AuthenticationAWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthenticationError.service(message: \"Session error: service(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.client(ClientRuntime.ClientError.retryError(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.service(AWSCognitoIdentity.GetCredentialsForIdentityOutputError.invalidIdentityPoolConfigurationException(AWSCognitoIdentity.InvalidIdentityPoolConfigurationException(_headers: Optional(x-amzn-ErrorType: InvalidIdentityPoolConfigurationException:, \\nContent-Type: application/x-amz-json-1.1, \\nConnection: keep-alive, \\nx-amzn-RequestId: 30935a6f-8195-438e-8bfe-93e5ff98322c, \\nContent-Length: 143, \\nStrict-Transport-Security: max-age=31536000; includeSubDomains, \\nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool., \\nDate: Wed, 09 Aug 2023 04:59:07 GMT), _statusCode: Optional(http_status_400), _message: Optional(\\\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\\\"), _requestID: Optional(\\\"30935a6f-8195-438e-8bfe-93e5ff98322c\\\"), _retryable: false, _isThrottling: false, _type: ClientRuntime.ErrorType.client, message: Optional(\\\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\\\"))), \\nStatus Code: http_status_400 \\n Strict-Transport-Security: max-age=31536000; includeSubDomains, \\nContent-Length: 143, \\nContent-Type: application/x-amz-json-1.1, \\nConnection: keep-alive, \\nx-amzn-RequestId: 30935a6f-8195-438e-8bfe-93e5ff98322c, \\nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool., \\nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:, \\nDate: Wed, 09 Aug 2023 04:59:07 GMT)), nil))\")";
        };
        "AuthorizationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthorizationError.sessionError(AWSCognitoAuthPlugin.FetchSessionError.service(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.client(ClientRuntime.ClientError.retryError(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.service(AWSCognitoIdentity.GetCredentialsForIdentityOutputError.invalidIdentityPoolConfigurationException(AWSCognitoIdentity.InvalidIdentityPoolConfigurationException(_headers: Optional(Connection: keep-alive, \nx-amzn-RequestId: 30935a6f-8195-438e-8bfe-93e5ff98322c, \nStrict-Transport-Security: max-age=31536000; includeSubDomains, \nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:, \nContent-Type: application/x-amz-json-1.1, \nDate: Wed, 09 Aug 2023 04:59:07 GMT, \nContent-Length: 143, \nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool.), _statusCode: Optional(http_status_400), _message: Optional(\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\"), _requestID: Optional(\"30935a6f-8195-438e-8bfe-93e5ff98322c\"), _retryable: false, _isThrottling: false, _type: ClientRuntime.ErrorType.client, message: Optional(\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\"))), \nStatus Code: http_status_400 \n Connection: keep-alive, \nx-amzn-RequestId: 30935a6f-8195-438e-8bfe-93e5ff98322c, \nStrict-Transport-Security: max-age=31536000; includeSubDomains, \nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:, \nContent-Type: application/x-amz-json-1.1, \nDate: Wed, 09 Aug 2023 04:59:07 GMT, \nContent-Length: 143, \nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool.)), nil)), noCredentials)";
        };
    };
}

@howardkitto
Copy link
Author

howardkitto commented Aug 9, 2023

Thanks @harsh62. That has certainly helped me but now it looks like the iam role permissions are wrong. Can you tell me what permissions it needs (normally I would be able to tell from cloudwatch but that doesn't work in this case)

2023-08-09 09:24:41.387167+0100 Peakflow[93179:2639804] [AWSAuthFederateToIdentityPoolTask] Starting execution
2023-08-09 09:24:41.387984+0100 Peakflow[93179:2639804] [AWSAuthTaskHelper] Check if authstate configured
2023-08-09 09:24:41.388112+0100 Peakflow[93179:2639804] [AWSAuthTaskHelper] Auth state configured
2023-08-09 09:24:41.388375+0100 Peakflow[93179:2639804] [AWSAuthFederateToIdentityPoolTask] Waiting for federation to complete
2023-08-09 09:24:41.388472+0100 Peakflow[93179:2640000] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeFederationToIdentityPool.swift Starting execution
2023-08-09 09:24:41.388518+0100 Peakflow[93179:2639999] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.notStarted" =             {
            };
        };
    };
}
2023-08-09 09:24:41.388596+0100 Peakflow[93179:2640000] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InitializeFederationToIdentityPool.swift Sending event FetchAuthSessionEvent.fetchAuthenticatedIdentityID
2023-08-09 09:24:41.391317+0100 Peakflow[93179:2640000] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Starting execution
2023-08-09 09:24:41.391396+0100 Peakflow[93179:2639999] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.fetchingIdentityID" =             {
            };
        };
    };
}
2023-08-09T09:24:41+0100 info CognitoIdentityClient : [Logging] Request: POST https:443 
 Path: / 
 X-Amz-Target: AWSCognitoIdentityService.GetId, 
User-Agent: aws-sdk-swift/1.0 api/cognito-identity/1.0 os/iOS/16.4.0 lang/swift/5.8 lib/amplify-swift/2.11.4, 
Content-Type: application/x-amz-json-1.1, 
x-amz-user-agent: aws-sdk-swift/1.0, 
Host: cognito-identity.eu-west-2.amazonaws.com, 
Content-Length: 886 
 Optional([])
2023-08-09T09:24:41+0100 info SerialExecutor : [Logging] Creating connection pool for Optional("https://cognito-identity.eu-west-2.amazonaws.com/?")with max connections: 50
2023-08-09T09:24:41+0100 info CRTClientEngine : [Logging] Connection was acquired to: Optional("https://cognito-identity.eu-west-2.amazonaws.com/?")
2023-08-09 09:24:42.000532+0100 Peakflow[93179:2639999] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Sending event FetchAuthSessionEvent.fetchedIdentityID
2023-08-09 09:24:42.001110+0100 Peakflow[93179:2640001] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.fetchingAWSCredentials" =             {
            };
        };
    };
}
2023-08-09 09:24:42.001159+0100 Peakflow[93179:2639804] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/FetchAuthAWSCredentials.swift Starting execution
2023-08-09T09:24:42+0100 info CognitoIdentityClient : [Logging] Request: POST https:443 
 Path: / 
 Content-Length: 882, 
X-Amz-Target: AWSCognitoIdentityService.GetCredentialsForIdentity, 
Content-Type: application/x-amz-json-1.1, 
x-amz-user-agent: aws-sdk-swift/1.0, 
User-Agent: aws-sdk-swift/1.0 api/cognito-identity/1.0 os/iOS/16.4.0 lang/swift/5.8 lib/amplify-swift/2.11.4, 
Host: cognito-identity.eu-west-2.amazonaws.com 
 Optional([])
2023-08-09T09:24:42+0100 info SerialExecutor : [Logging] Creating connection pool for Optional("https://cognito-identity.eu-west-2.amazonaws.com/?")with max connections: 50
2023-08-09T09:24:42+0100 info CRTClientEngine : [Logging] Connection was acquired to: Optional("https://cognito-identity.eu-west-2.amazonaws.com/?")
2023-08-09 09:24:42.619083+0100 Peakflow[93179:2640001] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/FetchAuthAWSCredentials.swift Sending event FetchAuthSessionEvent.throwError
2023-08-09 09:24:42.619386+0100 Peakflow[93179:2639999] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InformSessionError.swift Starting execution
2023-08-09 09:24:42.620414+0100 Peakflow[93179:2639999] [AWSCognitoAuthPlugin] AWSCognitoAuthPlugin/InformSessionError.swift Sending event AuthorizationEvent.receivedSessionError
2023-08-09 09:24:42.629298+0100 Peakflow[93179:2639804] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.federatingToIdentityPool" =         {
        };
        "AuthorizationState.federatingToIdentityPool" =         {
            "FetchSessionState.error" =             {
                error = "AWSCognitoAuthPlugin.FetchSessionError.service(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.client(ClientRuntime.ClientError.retryError(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.service(AWSCognitoIdentity.GetCredentialsForIdentityOutputError.invalidIdentityPoolConfigurationException(AWSCognitoIdentity.InvalidIdentityPoolConfigurationException(_headers: Optional(Date: Wed, 09 Aug 2023 08:24:42 GMT, \nContent-Length: 143, \nConnection: keep-alive, \nStrict-Transport-Security: max-age=31536000; includeSubDomains, \nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool., \nx-amzn-RequestId: c13f89ca-b9d4-4f49-94aa-cf86190ae58c, \nContent-Type: application/x-amz-json-1.1, \nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:), _statusCode: Optional(http_status_400), _message: Optional(\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\"), _requestID: Optional(\"c13f89ca-b9d4-4f49-94aa-cf86190ae58c\"), _retryable: false, _isThrottling: false, _type: ClientRuntime.ErrorType.client, message: Optional(\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\"))), \nStatus Code: http_status_400 \n Date: Wed, 09 Aug 2023 08:24:42 GMT, \nContent-Length: 143, \nConnection: keep-alive, \nStrict-Transport-Security: max-age=31536000; includeSubDomains, \nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool., \nx-amzn-RequestId: c13f89ca-b9d4-4f49-94aa-cf86190ae58c, \nContent-Type: application/x-amz-json-1.1, \nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:)), nil))";
            };
        };
    };
}
Failed to federate to identity pool with error: AuthError: Invalid identity pool configuration. Check assigned IAM roles for this pool.
Recovery suggestion: Make sure that the amplify configuration passed to Auth plugin is valid
2023-08-09 09:24:42.636670+0100 Peakflow[93179:2639804] [AWSCognitoAuthPlugin] Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthenticationError.service(message: \"Session error: service(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.client(ClientRuntime.ClientError.retryError(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.service(AWSCognitoIdentity.GetCredentialsForIdentityOutputError.invalidIdentityPoolConfigurationException(AWSCognitoIdentity.InvalidIdentityPoolConfigurationException(_headers: Optional(x-amzn-ErrorType: InvalidIdentityPoolConfigurationException:, \\nStrict-Transport-Security: max-age=31536000; includeSubDomains, \\nx-amzn-RequestId: c13f89ca-b9d4-4f49-94aa-cf86190ae58c, \\nConnection: keep-alive, \\nDate: Wed, 09 Aug 2023 08:24:42 GMT, \\nContent-Type: application/x-amz-json-1.1, \\nContent-Length: 143, \\nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool.), _statusCode: Optional(http_status_400), _message: Optional(\\\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\\\"), _requestID: Optional(\\\"c13f89ca-b9d4-4f49-94aa-cf86190ae58c\\\"), _retryable: false, _isThrottling: false, _type: ClientRuntime.ErrorType.client, message: Optional(\\\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\\\"))), \\nStatus Code: http_status_400 \\n Strict-Transport-Security: max-age=31536000; includeSubDomains, \\nDate: Wed, 09 Aug 2023 08:24:42 GMT, \\nx-amzn-RequestId: c13f89ca-b9d4-4f49-94aa-cf86190ae58c, \\nContent-Type: application/x-amz-json-1.1, \\nContent-Length: 143, \\nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool., \\nConnection: keep-alive, \\nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:)), nil))\")";
        };
        "AuthorizationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthorizationError.sessionError(AWSCognitoAuthPlugin.FetchSessionError.service(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.client(ClientRuntime.ClientError.retryError(ClientRuntime.SdkError<AWSCognitoIdentity.GetCredentialsForIdentityOutputError>.service(AWSCognitoIdentity.GetCredentialsForIdentityOutputError.invalidIdentityPoolConfigurationException(AWSCognitoIdentity.InvalidIdentityPoolConfigurationException(_headers: Optional(x-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool., \nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:, \nContent-Length: 143, \nContent-Type: application/x-amz-json-1.1, \nConnection: keep-alive, \nStrict-Transport-Security: max-age=31536000; includeSubDomains, \nx-amzn-RequestId: c13f89ca-b9d4-4f49-94aa-cf86190ae58c, \nDate: Wed, 09 Aug 2023 08:24:42 GMT), _statusCode: Optional(http_status_400), _message: Optional(\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\"), _requestID: Optional(\"c13f89ca-b9d4-4f49-94aa-cf86190ae58c\"), _retryable: false, _isThrottling: false, _type: ClientRuntime.ErrorType.client, message: Optional(\"Invalid identity pool configuration. Check assigned IAM roles for this pool.\"))), \nStatus Code: http_status_400 \n Date: Wed, 09 Aug 2023 08:24:42 GMT, \nConnection: keep-alive, \nContent-Type: application/x-amz-json-1.1, \nStrict-Transport-Security: max-age=31536000; includeSubDomains, \nContent-Length: 143, \nx-amzn-RequestId: c13f89ca-b9d4-4f49-94aa-cf86190ae58c, \nx-amzn-ErrorType: InvalidIdentityPoolConfigurationException:, \nx-amzn-ErrorMessage: Invalid identity pool configuration. Check assigned IAM roles for this pool.)), nil)), noCredentials)";
        };
    };
}

Here are the role details:

    "Role": {
        "Path": "/",
        "RoleName": "###-authRole",
        "RoleId": "###",
        "Arn": "###",
        "CreateDate": "2023-08-04T00:31:34+00:00",
        "AssumeRolePolicyDocument": {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Effect": "Allow",
                    "Principal": {
                        "Federated": "cognito-identity.amazonaws.com"
                    },
                    "Action": "sts:AssumeRoleWithWebIdentity",
                    "Condition": {
                        "StringEquals": {
                            "cognito-identity.amazonaws.com:aud": "###"
                        },
                        "ForAnyValue:StringLike": {
                            "cognito-identity.amazonaws.com:amr": "authenticated"
                        }
                    }
                }
            ]
        },
        "Description": "",
        "MaxSessionDuration": 3600,
        "Tags": [
            {
                "Key": "user:Application",
                "Value": "Peakflow"
            },
            {
                "Key": "user:Stack",
                "Value": "august"
            }
        ],
        "RoleLastUsed": {}
    }
}

Trust Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "cognito-identity.amazonaws.com"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "cognito-identity.amazonaws.com:aud": "###"
                },
                "ForAnyValue:StringLike": {
                    "cognito-identity.amazonaws.com:amr": "authenticated"
                }
            }
        }
    ]
}

and

{
    "Role": {
        "Path": "/",
        "RoleName": "###-unauthRole",
        "RoleId": "###",
        "Arn": "###",
        "CreateDate": "2023-08-04T00:31:34+00:00",
        "AssumeRolePolicyDocument": {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Effect": "Allow",
                    "Principal": {
                        "Federated": "cognito-identity.amazonaws.com"
                    },
                    "Action": "sts:AssumeRoleWithWebIdentity",
                    "Condition": {
                        "StringEquals": {
                            "cognito-identity.amazonaws.com:aud": "###"
                        },
                        "ForAnyValue:StringLike": {
                            "cognito-identity.amazonaws.com:amr": "unauthenticated"
                        }
                    }
                }
            ]
        },
        "Description": "",
        "MaxSessionDuration": 3600,
        "Tags": [
            {
                "Key": "user:Application",
                "Value": "Peakflow"
            },
            {
                "Key": "user:Stack",
                "Value": "august"
            }
        ],
        "RoleLastUsed": {}
    }
}

Trust policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "cognito-identity.amazonaws.com"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "cognito-identity.amazonaws.com:aud": ###"
                },
                "ForAnyValue:StringLike": {
                    "cognito-identity.amazonaws.com:amr": "unauthenticated"
                }
            }
        }
    ]
}

@harsh62
Copy link
Member

harsh62 commented Aug 9, 2023

@adam-a @howardkitto

I guess your role and attributes for access control are not correctly configured. To see things work set claim mapping to inactive and federating into identity pools should work for you.

image

But I strongly suggest to figure out what is not correctly configured between your attributes and role.

@adam-a
Copy link

adam-a commented Aug 9, 2023

@harsh62 So that worked -- sorta!

Successfully federated user to identity pool with result: 2023-08-09 10:49:06.878174-0700 Wallr[34993:3095988] [AuthenticationAWSCognitoAuthPlugin] Auth state change:

However, I don't see the user anywhere in my user pool on Cognito.

Also, I was wondering if you had an example of a correctly configured attribute/role pair anywhere.

P.S thank you so much for being so helpful regarding this issue.

@harsh62
Copy link
Member

harsh62 commented Aug 9, 2023

@adam-a

However, I don't see the user anywhere in my user pool on Cognito.

I guess there is some confusion around that. federateToIdentityPool API only federates the user into the identity pool. This means that you will see a new identity created in your identity pool.

To be clear, this API is not meant to federate in the User Pools. Hence, the new user not appearing in your user pool.

Unfortunately, there is no API at the moment to federate into user pools. If you need this feature, you would need to use HostedUI (i.e. signInWithWebUI API).

There is a feature request open #1121 to create an API that would federate into user pools and our team is looking to prioritize it in the near future.

@harsh62 harsh62 added the closing soon This issue will be closed in 7 days unless further comments are made. label Aug 9, 2023
@howardkitto
Copy link
Author

howardkitto commented Aug 10, 2023

Thanks @harsh62 I got a success - by turning off the claim mapping. However this is useless if I can't map this identity to a userpool. Is there a way we can get this issue higher up in the priority list? Or are there some instructions about how to do this ourselves so that I can use this identity with api gateway?

Screenshot 2023-08-10 at 07 32 09

Thanks so much for your help with this

Successfully federated user to identity pool with result: FederateToIdentityPoolResult(credentials: 2023-08-10 07:07:07.325451+0100 ###[97882:2754554] [AWSCognitoAuthPlugin] Credential Store state change:

success(AWSCognitoAuthPlugin.CredentialStoreData.amplifyCredentials(identityPoolWithFederation))
2023-08-10 07:07:07.325563+0100 ###[97882:2754554] [AWSCognitoAuthPlugin] Credential Store state change:

idle
["sessionToken": "IQ*****==", "secretAccessKey": "cx*****+N", "expiration": 2023-08-10 07:07:07 +0000, "accessKey": "AS*****XU"], identityId: "####")

@CoryZestDev
Copy link

CoryZestDev commented Aug 10, 2023

@harsh62 I just want to clarify on your earlier reply,
"5.) Enter your bundle identifier for the app as the Services ID."
Is it really supposed to be the app's bundle ID because the setup flow make it seem like it supposed to be a separate Services ID
Screenshot 2023-08-10 at 7 11 20 PM

@harsh62
Copy link
Member

harsh62 commented Aug 11, 2023

@CoryZestDev Right. You are correct. I have corrected the step as follows:

  1. Enter the Services ID of the OAuth project you created with Apple Developer. For more information, see Authenticating users with Sign in with Apple in Sign in with Apple Documentation.

How to register a Services ID

  1. On the Identifiers page, choose the App IDs menu, then Services IDs. Choose the + icon.

  2. On the Register a New Identifier page, choose Services IDs, and then choose Continue.

  3. On the Register a Services ID page, do the following:

  • Under Description, type a description.
  • Under Identifier, type an identifier. Make a note of the services ID as you need this value to configure Apple as a provider in your identity pool.
  • Select Sign In with Apple and then choose Configure.
  • On the Web Authentication Configuration page, choose a Primary App ID. Under Website URLs, choose the + icon. For Domains and Subdomains, enter the domain name of your app. In Return URLs, enter the callback URL where the authorization redirects the user after they authenticate through Sign in with Apple.
  • Choose Next.
  • Choose Continue, and then choose Register.

@harsh62
Copy link
Member

harsh62 commented Aug 14, 2023

Please watch #1121 to get updates on federation to User Pools.

@harsh62 harsh62 closed this as completed Aug 14, 2023
@github-actions github-actions bot removed pending-community-response Issue is pending response from the issue requestor closing soon This issue will be closed in 7 days unless further comments are made. labels Aug 14, 2023
@SwiftBeta
Copy link

Hello, I'm facing the same issue. I have just added Sign In With Apple, and it's working perfectly when I use the Hosted UI Endpoint

amplify status

Screenshot 2023-12-23 at 10 28 56 Screenshot 2023-12-23 at 10 40 41


I can create users directly from my browser by tapping the Sign In With Apple button, here you can find 2 users created using Sign In with Apple directly from my browser:

Screenshot 2023-12-23 at 10 58 28


but when I try to create users using my app, I receive the error previously shared in this issue (and I use the same code):

// Button inside my SwiftUI View
SignInWithAppleButton(
      .signIn,
      onRequest: configure,
      onCompletion: handle
)
...

// Other class with Sign In With Apple related code
func configure(_ request: ASAuthorizationAppleIDRequest) {
    request.requestedScopes = [.email]
}

func handle(_ authResult: Result<ASAuthorization, Error>) {
    switch authResult {
    case .success(let authorization):
        guard
            let credential = authorization.credential as? ASAuthorizationAppleIDCredential,
            let identityToken = credential.identityToken
        else { return }
        
        signIn(with: identityToken)
        
    case .failure(let error):
        print(error)
    }
}

func signIn(with token: Data) {
    guard
        let tokenString = String(data: token, encoding: .utf8),
        let plugin = try? Amplify.Auth.getPlugin(for: "awsCognitoAuthPlugin") as? AWSCognitoAuthPlugin
    else {
        return
    }
    
    Task {
        do {
            print("🔥🔥🔥 Token \(tokenString)")
            
            let result = try await plugin.federateToIdentityPool(withProviderToken: tokenString,
                                                                 for: .apple)
            print("Successfully federated user to identity pool with result:", result)
        } catch {
            print("Failed to federate to identity pool with error:", error)
        }
    }
}

But the result is the same, I'm not Authorized

Auth state change:

{
    "AuthState.configured" =     {
        "AuthenticationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthenticationError.service(message: \"Session error: notAuthorized\")";
        };
        "AuthorizationState.error" =         {
            Error = "AWSCognitoAuthPlugin.AuthorizationError.sessionError(AWSCognitoAuthPlugin.FetchSessionError.notAuthorized, noCredentials)";
        };
    };
}

Here is my entire log when I press the Sign In With Apple button

🔥🔥🔥 Token [REDACTED]
2023-12-23T10:35:39+0100 info CognitoIdentityClient : [Logging] Request: POST https:443 
 Path: / 
 Host: cognito-identity.eu-west-3.amazonaws.com, 
Content-Type: application/x-amz-json-1.1, 
X-Amz-Target: AWSCognitoIdentityService.GetId, 
Content-Length: 929, 
User-Agent: aws-sdk-swift/1.0 ua/2.0 api/cognito_identity#1.0 os/ios#17.2.0 lang/swift#5.9 cfg/retry-mode#legacy 
 nil
2023-12-23T10:35:39+0100 info SerialExecutor : [Logging] Creating connection pool for cognito-identity.eu-west-3.amazonaws.com with max connections: 50
Starting execution
Check if authstate configured
Auth state configured
Waiting for federation to complete
Auth state change:
{
    "AuthState.configured" = {
        "AuthenticationState.federatingToIdentityPool" = {
        };
        "AuthorizationState.federatingToIdentityPool" = {
            "FetchSessionState.notStarted" = {
            };
        };
    };
}
AWSCognitoAuthPlugin/InitializeFederationToIdentityPool.swift Starting execution
AWSCognitoAuthPlugin/InitializeFederationToIdentityPool.swift Sending event FetchAuthSessionEvent.fetchAuthenticatedIdentityID
AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Starting execution
Auth state change:
{
    "AuthState.configured" = {
        "AuthenticationState.federatingToIdentityPool" = {
        };
        "AuthorizationState.federatingToIdentityPool" = {
            "FetchSessionState.fetchingIdentityID" = {
            };
        };
    };
}
2023-12-23T10:35:39+0100 info CRTClientEngine : [Logging] Connection was acquired to: Optional("https://cognito-identity.eu-west-3.amazonaws.com/")
2023-12-23T10:35:39+0100 info CRTClientEngine : [Logging] Using HTTP/1.1 connection
2023-12-23T10:35:39+0100 info HttpContent : [Logging] read 929 bytes from data
2023-12-23T10:35:40+0100 info CRTClientEngine : [Logging] Main headers received
2023-12-23T10:35:40+0100 info CRTClientEngine : [Logging] Body chunk received
2023-12-23T10:35:40+0100 info CRTClientEngine : [Logging] Request/response completed
2023-12-23T10:35:40+0100 info CognitoIdentityClient : [Logging] Request: POST https:443 
 Path: / 
 X-Amz-Target: AWSCognitoIdentityService.GetId, 
User-Agent: aws-sdk-swift/1.0 ua/2.0 api/cognito_identity#1.0 os/ios#17.2.0 lang/swift#5.9 cfg/retry-mode#legacy, 
Host: cognito-identity.eu-west-3.amazonaws.com, 
Content-Type: application/x-amz-json-1.1, 
Content-Length: 929 
 nil
[...]

AWSCognitoAuthPlugin/FetchAuthIdentityId.swift Sending event FetchAuthSessionEvent.throwError
AWSCognitoAuthPlugin/InformSessionError.swift Starting execution
AWSCognitoAuthPlugin/InformSessionError.swift Sending event AuthorizationEvent.receivedSessionError
Auth state change:
{
    "AuthState.configured" = {
        "AuthenticationState.federatingToIdentityPool" = {
        };
        "AuthorizationState.federatingToIdentityPool" = {
            "FetchSessionState.error" = {
                error = "AWSCognitoAuthPlugin.FetchSessionError.notAuthorized";
            };
        };
    };
}
Failed to federate to identity pool with error: AuthError: Not authorized error
Recovery suggestion: Check whether the given values are correct and the user is authorized to perform the operation
Auth state change:
{
    "AuthState.configured" = {
        "AuthenticationState.error" = {
            Error = "AWSCognitoAuthPlugin.AuthenticationError.service(message: \"Session error: notAuthorized\")";
        };
        "AuthorizationState.error" = {
            Error = "AWSCognitoAuthPlugin.AuthorizationError.sessionError(AWSCognitoAuthPlugin.FetchSessionError.notAuthorized, noCredentials)";
        };
    };
}

I removed all my config files and pulled again, just in case any change in my JSON files would fix the issue, but without luck. After executing amplify pull, my awsconfiguration and amplifyconfiguration files remain the same.

amplifyconfiguration.json

{
    "UserAgent": "aws-amplify-cli/2.0",
    "Version": "1.0",
    "api": {
        "plugins": {
            "awsAPIPlugin": {
                "Metrics": {
                    "endpointType": "GraphQL",
                    "endpoint": "https://[REDACTED].appsync-api.eu-west-3.amazonaws.com/graphql",
                    "region": "eu-west-3",
                    "authorizationType": "API_KEY",
                    "apiKey": "[REDACTED]"
                }
            }
        }
    },
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "UserAgent": "aws-amplify/cli",
                "Version": "0.1.0",
                "IdentityManager": {
                    "Default": {}
                },
                "AppSync": {
                    "Default": {
                        "ApiUrl": "https://[REDACTED].appsync-api.eu-west-3.amazonaws.com/graphql",
                        "Region": "eu-west-3",
                        "AuthMode": "API_KEY",
                        "ApiKey": "[REDACTED]",
                        "ClientDatabasePrefix": "Metrics_API_KEY"
                    },
                    "Metrics_AWS_IAM": {
                        "ApiUrl": "https://[REDACTED].eu-west-3.amazonaws.com/graphql",
                        "Region": "eu-west-3",
                        "AuthMode": "AWS_IAM",
                        "ClientDatabasePrefix": "Metrics_AWS_IAM"
                    }
                },
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "eu-west-3:[REDACTED]",
                            "Region": "eu-west-3"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "eu-west-[REDACTED]",
                        "AppClientId": "24uodve[REDACTED]",
                        "Region": "eu-west-3"
                    }
                },
                "Auth": {
                    "Default": {
                        "OAuth": {
                            "WebDomain": "metrics06[REDACTED].auth.eu-west-3.amazoncognito.com",
                            "AppClientId": "24uodve[REDACTED]",
                            "SignInRedirectURI": "mymetrics://",
                            "SignOutRedirectURI": "mymetrics://",
                            "Scopes": [
                                "phone",
                                "email",
                                "openid",
                                "profile",
                                "aws.cognito.signin.user.admin"
                            ]
                        },
                        "authenticationFlowType": "USER_SRP_AUTH",
                        "mfaConfiguration": "OFF",
                        "mfaTypes": [
                            "SMS"
                        ],
                        "passwordProtectionSettings": {
                            "passwordPolicyMinLength": 8,
                            "passwordPolicyCharacters": []
                        },
                        "signupAttributes": [
                            "EMAIL"
                        ],
                        "socialProviders": [
                            "APPLE"
                        ],
                        "usernameAttributes": [
                            "EMAIL"
                        ],
                        "verificationMechanisms": [
                            "EMAIL"
                        ]
                    }
                }
            }
        }
    }
}

Do you have any clue what I should try next?

It's seems like something is wrong in my iOS app (maybe a configuration file?) because all the flow is working on web (so, Apple part is correctly configured Service Id, Certificate, etc)

Thank you,

@orira
Copy link

orira commented Mar 3, 2024

Same issue here spent hours banging my head on this issue, when using the native button never works I get the Unauthorized error reported above.

SignInWithAppleButton( onRequest: viewModel.configureAWSAppleSignInRequest, onCompletion: viewModel.handleAWSAppleSignInResult )

but when using this method invoked from a standard button

let signInResult = try await Amplify.Auth.signInWithWebUI(for: .apple)

everything works fine, seems like a bug with the amplify implementation to me

@harsh62
Copy link
Member

harsh62 commented Mar 4, 2024

Reiterating. Amplify ATM only supports federation to user pools using the signInWithWebUI API. Please follow #1121 for updates on supporting federation to user pools natively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the Auth category question General question
Projects
None yet
Development

No branches or pull requests

6 participants