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

Failed execution for Auth.socialWebUISignInAPI with error: AuthError: Make sure that the amplify configuration passed to Auth plugin is valid #3861

Open
ChurikiTenna opened this issue Sep 13, 2024 · 4 comments
Labels
auth Issues related to the Auth category question General question

Comments

@ChurikiTenna
Copy link

ChurikiTenna commented Sep 13, 2024

Describe the bug

It is not a bug, I think I am doing something wrong.
I followed this steps to Sign in with Apple, but get this error:

Failed execution for Auth.socialWebUISignInAPI with error:
AuthError: Make sure that the amplify configuration passed to Auth plugin is valid

I have checked all the values are correct at least 3 times. What else do I need to check?

One concern, amplify update auth require key id before creating the actual key. how is it possible to get a Key id before creating them?

Steps To Reproduce

Steps to reproduce the behavior:
1. Create an App ID
2. Create a Service ID
3. Create a Key
4. Do this in terminal
% amplify update auth
Please note that certain attributes may not be overwritten if you choose to use defaults settings.

You have configured resources that might depend on this Cognito resource.  Updating this Cognito resource could have unintended side effects.

Using service: Cognito, provided by: awscloudformation
 What do you want to do? Apply default configuration with Social Provider (Feder
ation)
 What domain name prefix do you want to use? iris26e476d4-26e476d4
 Enter your redirect signin URI: iris://
? Do you want to add another redirect signin URI No
 Enter your redirect signout URI: iris://
? Do you want to add another redirect signout URI No
 Select the identity providers you want to configure for your user pool: Sign in
 with Apple
  
 You've opted to allow users to authenticate via Sign in with Apple. If you have
n't already, you'll need to go to https://developer.apple.com/account/#/welcome 
and configure Sign in with Apple. 
 
 Enter your Services ID for your OAuth flow:  com.zasso.iris
 Enter your Team ID for your OAuth flow:  86USSQ2K46
 Enter your Key ID for your OAuth flow:  4A772NX2MB
 Enter your Private Key for your OAuth flow (entire key without line breaks):  -
----BEGIN PRIVATE KEY-----MIG...EN-----END PRIVATE KEY-----
 Successfully updated AdminQueriese13453b3 function locally
 Successfully updated AdminQueries API locally
 Successfully updated auth resource iris1ef6f127 locally

 Some next steps:
"amplify push" will build all your local back...

 Successfully updated resource update locally

 Some next steps:
"amplify push" will build all your local back...

tenna@chuurikitennanoiMac Iris % amplify push       
 Fetching updates to backend environment: dev from the cloud.⠋ Building resourc Building resource api/iris
⚠️  WARNING: your GraphQL API currently allows public create, read, update, and delete access to all models via an API Key. To configure PRODUCTION-READY authorization rules, review: https://docs.amplify.aws/cli/graphql/authorization-rules

 Building resource api/iris✅ GraphQL schema compiled successfully.

Edit your schema at /Users/tenna/Desktop/Iris/amplify/backend/api/iris/schema.graphql or place .graphql files in a directory at /Users/tenna/Desktop/Iris/amplify/backend/api/iris/schema
 Successfully pulled backend environment dev from the cloud.

    Current Environment: dev
    
┌──────────┬──────────────────────┬───────────┬───────────────────┐
 Category  Resource name         Operation  Provider plugin   
├──────────┼──────────────────────┼───────────┼───────────────────┤
 Auth      iris1ef6f127          Update     awscloudformation 
├──────────┼──────────────────────┼───────────┼───────────────────┤
 Auth      userPoolGroups        No Change  awscloudformation 
├──────────┼──────────────────────┼───────────┼───────────────────┤
 Function  AdminQueriese13453b3  No Change  awscloudformation 
├──────────┼──────────────────────┼───────────┼───────────────────┤
 Api       AdminQueries          No Change  awscloudformation 
├──────────┼──────────────────────┼───────────┼───────────────────┤
 Api       iris                  No Change  awscloudformation 
└──────────┴──────────────────────┴───────────┴───────────────────┘
 Are you sure you want to continue? (Y/n) · yes

Deployment completed.
Deploying root stack Iris [ =================================------- ]
	amplify-iris-dev-bc369         AWS::CloudFormation::Stack     UPDATE_
	apiiris                        AWS::CloudFormation::Stack     UPDATE_
	authiris1ef6f127               AWS::CloudFormation::Stack     UPDATE_
	authuserPoolGroups             AWS::CloudFormation::Stack     UPDATE_
	functionAdminQueriese13453b3   AWS::CloudFormation::Stack     UPDATE_
	apiAdminQueries                AWS::CloudFormation::Stack     UPDATE_
Deployed auth iris1ef6f127 [ ======================================== 
	HostedUICustomResource         AWS::Lambda::Function          CREATE_
	HostedUIProvidersCustomResour AWS::Lambda::Function          CREATE_
	HostedUICustomResourcePolicy   AWS::IAM::Policy               CREATE_
	HostedUIProvidersCustomResour AWS::IAM::Policy               CREATE_
	HostedUICustomResourceLogPoli AWS::IAM::Policy               CREATE_
	HostedUIProvidersCustomResour AWS::IAM::Policy               CREATE_
Deployed auth userPoolGroups [ =======================================

Deployment state saved successfully.

GraphQL transformer version: 2
Hosted UI Endpoint: https://iris26e476...
Test Your Hosted UI Endpoint: https://iris26e4...

5. Update a Service ID (Add Domains starting with iris26..., Return URLs starting with https://iris26.../oauth2/idpresponse)

6. Add these to the info.plist file
<key>CFBundleURLTypes</key>
         <array>
             <dict>
                 <key>CFBundleURLSchemes</key>
                 <array>
                     <string>iris</string>
                 </array>
             </dict>
         </array>

7. Launch the app and tap the AppleSignInButton.

SignInWithAppleButton(.signUp)
                { request in
                    request.requestedScopes = [.fullName, .email]
                } onCompletion: { authResults in
                    switch authResults {
                    case .success(let authResults):
                        self.signInWithApple(authResults: authResults)
                    case .failure(let error):
                        print(error.localizedDescription)
                    }
                }
...
func signInWithApple(authResults: ASAuthorization) {
        print("signInWithApple")
        guard let appleIDCredential = authResults.credential as? ASAuthorizationAppleIDCredential else {
            print("Failed to get AppleID credentials")
            return
        }
        guard let identityTokenData = appleIDCredential.identityToken,
              let identityToken = String(data: identityTokenData, encoding: .utf8) else {
            print("Unable to fetch identity token")
            return
        }
        Task {
            if let fullName = appleIDCredential.fullName {
                //self.givenName = fullName.givenName ?? ""
                self.familyName = fullName.familyName ?? ""
            }
            self.email = appleIDCredential.email ?? ""
            
            var result = try await Amplify.Auth.signInWithWebUI(for: .apple, presentationAnchor: UIWindow())
            if result.isSignedIn {
                isSignedIn = result.isSignedIn
            }
        }
    }

8. Get the error.

Expected behavior

Be able to Sign in with Apple

Amplify Framework Version

2.39.0

Amplify Categories

Auth

Dependency manager

Swift PM

Swift version

latest

CLI version

12.12.6

Xcode version

Xcode 15.4 Build version 15F31d

Relevant log output

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


signInWithApple
Starting execution for Auth.socialWebUISignInAPI
Check if authstate configured
Auth state configured
Wait for a valid state
Start signIn flow
Sending cancel signIn
Wait for signIn to cancel
Failed execution for Auth.socialWebUISignInAPI with error:
AuthError: Make sure that the amplify configuration passed to Auth plugin is valid
```

Is this a regression?

Yes

Regression additional context

No response

Platforms

iOS

OS Version

iOS 17

Device

iPhone 11 & 15

Specific to simulators

No response

Additional context

No response

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Sep 13, 2024
@vincetran vincetran added auth Issues related to the Auth category question General question labels Sep 13, 2024
@vincetran
Copy link
Member

Hi @ChurikiTenna,
Can you elaborate what you mean by

One concern, amplify update auth require key id before creating the actual key. how is it possible to get a Key id before creating them?

The key ID is created by Apple during the "Setup Your Auth Provider" step as found here which is the step before you call `amplify update auth``

Thanks for your detailed reproduction steps. Just wanted to clarify something since it wasn't explicitly called out, between steps 4 and 5 in your provided steps, did you provide Apple with the hosted UI endpoint URL that was generated in step 4? It's the last section in the Configure Auth Category section right before the Update Info.plist step.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Sep 13, 2024
@ChurikiTenna
Copy link
Author

Hi @vincetran ! Thank you for your response.

The key seems to be created after amplify update auth.
スクリーンショット2024-09-16(10 20 08)
The Setup Your Auth Provider step only include creating a App ID and Service ID.
Am I misunderstanding something?

And yes, I have provided hosted UI endpoint URL.
スクリーンショット 2024-09-16 10 27 14

@github-actions github-actions bot added pending-maintainer-response Issue is pending response from an Amplify team member and removed pending-maintainer-response Issue is pending response from an Amplify team member labels Sep 16, 2024
@vincetran vincetran removed the pending-triage Issue is pending triage label Sep 16, 2024
@ChurikiTenna
Copy link
Author

ChurikiTenna commented Sep 17, 2024

@harsh62
Can same Service ID and App ID not exist? I get these errors.

  1. When I try to create a Service ID that matches BundleId of the app
スクリーンショット 2024-09-17 9 09 08 スクリーンショット 2024-09-17 9 09 33
  1. When I try to create a App ID that matches the Service ID
スクリーンショット 2024-09-17 9 17 17
  1. When I try to create a brand new App ID and Service ID with the same ID.
    App ID can be created.
スクリーンショット 2024-09-17 9 19 45 Service ID with the same ID cannot be created. スクリーンショット 2024-09-17 9 19 25

Please correct me if I am wrong.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Sep 17, 2024
@harsh62
Copy link
Member

harsh62 commented Sep 17, 2024

Ahh .. May be I confused you a little. Let me clarify a few things..

  1. When you are using WebUI (also called HostedUI), you don't need to create a specific Sign In With Apple button.. Native SIWA is not a supported feature in user pools. So you should just use the following.

                var result = try await Amplify.Auth.signInWithWebUI(for: .apple, presentationAnchor: UIWindow())
                if result.isSignedIn {
                    isSignedIn = result.isSignedIn
                }
    
  2. Would you be able to share your amplifyconfiguration.json that gets created? (redacted all the sensitive information)

  3. Make sure the services id matches the one that was created in the apple account.
    Enter your Services ID for your OAuth flow: com.zasso.iris

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Sep 17, 2024
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

3 participants