0

I use django-rest-sms-auth, which provides such providers as Twilio, Megafon, smsaero. But I've created another provider - Amazon SNS.

    def send_amazon_sms(self):
        client = boto3.client('sns', aws_access_key_id=self.conf.SMS_PROVIDER_LOGIN,
                              aws_secret_access_key=self.conf.SMS_PROVIDER_PASSWORD, region_name='eu-north-1')
        client.publish(PhoneNumber=str(self.to), Message=self.message)

    def send_sms(self):
        return self.send_amazon_sms()
//but it returns: 
**botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter PhoneNumber, value: +996550102030, type: <class 'phonenumber_field.phonenumber.PhoneNumber'>, valid types: <class 'str'>**

Could you help me, why myphone_num is not correct? P.S. when I'm running this locally with my credentials and phone number as a separate python file, everything works fine

nuraska90
  • 27
  • 6
  • What is `self.to`? – Marcin Nov 09 '21 at 07:28
  • @Marcin it is a phone_num from my ```@app.task def send_sms_async(identifier: int): code_instance = PhoneCode.objects.filter(pk=identifier).first() if code_instance: provider_class = get_provider_class() provider = provider_class( to=code_instance.phone_number, message=code_instance.message, conf=conf ) provider.send_sms() ``` – nuraska90 Nov 09 '21 at 07:45

0 Answers0