Can not get user after sign in with Apple ID
I use AWS Cognito to sign in with Apple ID. The setup helped me successfully sign in using the function:
AWSMobileClient.default().federatedSignIn(providerName: IdentityProvider.apple.rawValue, token: identityTokenString)
As you can see from the log in the console.
However, I’m still encountering three issues, and I think the first two might be related:
- After signing in successfully, I cannot retrieve the user information when using the function
AWSMobileClient.default().getUserAttributes().I get error 26 (notSignIn??) - On the AWS console, the ‘User’ tab does not show any additional users even though the sign-in was reported as successful.
I’m not sure if there is any configuration missing on the AWS Console side, but I’m confident I followed the instructions completely since the sign-in itself was successful.
Environment:
- SDK Version: AWSMobileClient (2.35.0)
- Dependency Manager: Cocoapods
- Swift Version : 5.9.2
Device Information (please complete the following information):
- Device: iPhone 11 (iOS 16.5.1)
- Simulator: iPhone 15( iOS 17.2)
Thanks you!
@BigVeila Thanks for submitting the issue. We'll work on reproducing the issue and provide an update here.
@BigVeila Federating into user pools is not a supported feature. What you are doing is federating into Identity Pools. Please track the feature request in Amplify for further updates on federating into user pools.
You can use WebUI API in Amplify to federate into user pools using SIWA.
@harsh62 thanks, I am using Amplify and I sign-in success, my user is added into user pool too. But I have more question. I can't sign out normally, I need to reset then configure Amplify again then sign-out. Do you have any idea about this?
@BigVeila Can you provide your configuration file (with sensitive details redacted) and sample code on how you configuring Amplify and signing in/out?
@phantumcode I have signed out successfully. Step 1 add
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>YOUR APP NAME</string>
</array>
</dict>
</array>
to info.plist so you don't have to reset the configuration before signing out.
Step 2 is to add options: .preferPrivateSession() to sign-in function, so that when signing out, the alert message won't appear.
I found that there is no specific sample or tutorial, I found them by testing and researching in existing issues. AWS should add to the documentation
@phantumcode I have one more question. I try to use sign-in without options: .preferPrivateSession(), then I sign-out, and sign-in again, always auto sign-in the last account. It does not show the web login any more. Do you have any idea about this?
without options: .preferPrivateSession()
This is because you are already into the identity provider. The sign out only signs you out from Cognito and not the identity provider.
@harsh62 So is there any way for me to completely sign out? Or is the only option to use preferPrivateSession()?
@BigVeila .. I would like to refer you to this comment I made on another issue which is similar to what you are seeing. https://github.com/aws-amplify/amplify-swift/issues/3593#issuecomment-2038048857
I would suggest you to use private session if you want the user to be not automatically logged in if they haven't logged out of the idp.