Search code examples
pythonsendgrid

Sendgrid Authenticate with API Keys


I got the following mail from SentGrid,

We are emailing to inform you of an upcoming requirement to update your authentication method with Twilio SendGrid to API keys exclusively by December 9th, 2020 in order to ensure uninterrupted service and improve the security of your account. Our records show that you have used basic authentication with username and password for one or more of your API requests with 1 users of your SendGrid account in the last 180 days.

Why API keys?

This is an effort to enhance security for all of our users. Using your account username and password for authentication is less secure than using an API Key. Unlike your username and password, API Keys are uniquely generated and can be set to limit the access and specify permissions for a given request.

What action is required?

Follow these steps to identify and replace your authentication method to API Keys and then implement Two-Factor Authentication (2FA) for enhanced security. What happens if no action is taken? On December 9th, 2020 we will no longer accept basic authentication with username and password, and we will be requiring 2FA to login to your account. If you attempt to authenticate your API requests or SMTP configuration with username and password for any of your users after that date, your requests will be rejected. We’d like to thank you in advance for your prompt attention to these requirements. If you’d like to learn more about how you can enhance the security of your account, view this post. If you have any questions or need assistance, please visit our documentation or reach out to our Support team. Thank you, The Twilio SendGrid Team

Presently I am sending mails to sendgrid by using following credentials,

EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_USE_TLS = False
EMAIL_PORT = 587
EMAIL_HOST_USER = 'xx@gmail.com'
EMAIL_HOST_PASSWORD = 'xxx'''

Is this change affect me?


Solution

  • Yes, once they force two factor authentication (2FA), your application will not be able to do basic authentication by just using username/email & password.
    So, you need to start using API keys.

    Migration is simple:

    • Login to sendgrid account
    • Goto https://app.sendgrid.com/settings/api_keys
    • "Generate API Key" - generate a new API key and copy paste to be used later
    • Code changes:
      • EMAIL_HOST_USER = 'apikey' (username should be this only)
      • EMAIL_HOST_PASSWORD = 'YOUR_API_KEY'
    • Test it

    If the changes work, you are good to go and have migrated from basic authentication to API keys.