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

Verification Codes are not sent for Amplify Auth #3530

Closed
dan-codes1 opened this issue Feb 18, 2024 · 5 comments
Closed

Verification Codes are not sent for Amplify Auth #3530

dan-codes1 opened this issue Feb 18, 2024 · 5 comments
Assignees
Labels
auth Issues related to the Auth category documentation Documentation improvements question General question

Comments

@dan-codes1
Copy link

Describe the bug

The api for sending confirmation codes to users' email does not work. The api does not return an error, but the verification code is just not sent.

The api I am using is: try await Amplify.Auth.sendVerificationCode(forUserAttributeKey: .email)
The console log for the api prints:
2024-02-18T11:16:29-0700 info CognitoIdentityProviderClient : [Logging] Request: POST https:443
Path: /
Content-Type: application/x-amz-json-1.1,
Host: cognito-idp.us-east-1.amazonaws.com,
User-Agent: aws-sdk-swift/1.0 ua/2.0 api/cognito_identity_provider#1.0 os/ios#17.2.0 lang/swift#5.9 cfg/retry-mode#legacy,
X-Amz-Target: AWSCognitoIdentityProviderService.GetUserAttributeVerificationCode,
Content-Length: 1134
nil
2024-02-18T11:16:29-0700 info SerialExecutor : [Logging] Creating connection pool for cognito-idp.us-east-1.amazonaws.com with max connections: 50
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Connection was acquired to: Optional("https://cognito-idp.us-east-1.amazonaws.com/")
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Using HTTP/1.1 connection
2024-02-18T11:16:29-0700 info HttpContent : [Logging] read 1134 bytes from data
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Main headers received
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Body chunk received
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Request/response completed
AuthCodeDeliveryDetails(destination: Amplify.DeliveryDestination.email(Optional("d***@g***")), attributeKey: Optional(Amplify.AuthUserAttributeKey.email))

But the email is not sent

Also:

I noticed a discrepancy between the amplify-swift documentation, and the amply-swift api.
The docs here: https://docs.amplify.aws/swift/build-a-backend/auth/managing-attributes/ say that to resend verification codes, you use api: let deliveryDetails = try await Amplify.Auth.resendConfirmationCode(forUserAttributeKey: .email) but that api seems to deprecated in Xcode for the amplify-swift 2.26.1 version.

Steps To Reproduce

1. Add auth to your app and enable email and sms for the attributes verification
2. After you sign up a user, try to call the `try await Amplify.Auth.sendVerificationCode(forUserAttributeKey: .email)` api.
3. Does it send the verification email?

Expected behavior

  1. I expect the email to be sent, since no error was raised in the code / app
  2. Update the amplify-swift docs or the api; which ever is outdated?

Amplify Framework Version

2.26.1

Amplify Categories

Auth

Dependency manager

Swift PM

Swift version

5.9.2

CLI version

12.10.1

Xcode version

15.2

Relevant log output

2024-02-18T11:16:29-0700 info CognitoIdentityProviderClient : [Logging] Request: POST https:443 
 Path: / 
 Content-Type: application/x-amz-json-1.1, 
Host: cognito-idp.us-east-1.amazonaws.com, 
User-Agent: aws-sdk-swift/1.0 ua/2.0 api/cognito_identity_provider#1.0 os/ios#17.2.0 lang/swift#5.9 cfg/retry-mode#legacy, 
X-Amz-Target: AWSCognitoIdentityProviderService.GetUserAttributeVerificationCode, 
Content-Length: 1134 
 nil
2024-02-18T11:16:29-0700 info SerialExecutor : [Logging] Creating connection pool for cognito-idp.us-east-1.amazonaws.com with max connections: 50
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Connection was acquired to: Optional("https://cognito-idp.us-east-1.amazonaws.com/")
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Using HTTP/1.1 connection
2024-02-18T11:16:29-0700 info HttpContent : [Logging] read 1134 bytes from data
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Main headers received
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Body chunk received
2024-02-18T11:16:29-0700 info CRTClientEngine : [Logging] Request/response completed
AuthCodeDeliveryDetails(destination: Amplify.DeliveryDestination.email(Optional("d***@g***")), attributeKey: Optional(Amplify.AuthUserAttributeKey.email))

Is this a regression?

No

Regression additional context

No response

Platforms

iOS

OS Version

iOS 16

Device

iPhone 15 pro

Specific to simulators

No response

Additional context

No response

@harsh62 harsh62 self-assigned this Feb 19, 2024
@harsh62 harsh62 added auth Issues related to the Auth category documentation Documentation improvements question General question labels Feb 19, 2024
@harsh62
Copy link
Member

harsh62 commented Feb 19, 2024

@dan-codes1 Thanks for opening the issue. I can acknowledge that the documentation needs to be updated and I can work on updating it as soon as possible.


Regarding the email not being sent, are you using the default email service provided by Cognito or Amazon SES. If you are using Amazon SES, In the sandbox, Amazon SES imposes restrictions on how many emails you can send and where you can send them.

If you are using the default Amazon Cognito provided email service and using a custom email address. Before you can use your custom email address, you must verify it with Amazon SES and grant Amazon Cognito permission to use this address.

Just make sure you also check your Spam folder on the receivers mailbox.

From the logs, i can see that everything looks good, so it is definitely a service configuration that might be an issue.

@dan-codes1
Copy link
Author

@harsh62 I am using the default cognito address. I noticed that the confirmation email is sent initially but if for some reason, the app decides to resend it, the email does not get sent; even after refereshing the app (closing and opening it).

@harsh62
Copy link
Member

harsh62 commented Feb 21, 2024

@dan-codes1 Just curious if the deprecated API is working and sending the email multiple times?

@dan-codes1
Copy link
Author

@harsh62 It actually works fine and sends all emails for both APIs. It turns out that subsequent emails are sent to the users spam.

Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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 documentation Documentation improvements question General question
Projects
None yet
Development

No branches or pull requests

2 participants