jensgrnb commented on issue #18495:
URL: https://github.com/apache/airflow/issues/18495#issuecomment-927960288


   Thanks for the code pointer, I'll double check the pasted api key!
   
   On Mon, 27 Sept 2021 at 16:51, Jarek Potiuk ***@***.***>
   wrote:
   
   > I did not use sendgrid so I am not sure but from the code it looks like
   > API_KEY is taken from connection password. I do not think host is ever
   > used. You just have to make sure your connection is named
   > 'sendgrid_default". You can also try env variable to test if your key is
   > correct (see below):
   >
   > The error 400 has nothing to do with password - it is Bad request - so if
   > anything this might be a bad version of sendgrid dependency, wrong
   > provider, or maybe wrong format of the KEY? You need to consult sendgrid
   > docs:
   >
   > From:
   > 
https://github.com/apache/airflow/blob/main/airflow/providers/sendgrid/utils/emailer.py
   >
   > def _post_sendgrid_mail(mail_data: Dict, conn_id: str = 
"sendgrid_default") -> None:
   >     api_key = None
   >     try:
   >         conn = BaseHook.get_connection(conn_id)
   >         api_key = conn.password
   >     except AirflowException:
   >         pass
   >     if api_key is None:
   >         warnings.warn(
   >             "Fetching Sendgrid credentials from environment variables will 
be deprecated in a future "
   >             "release. Please set credentials using a connection instead.",
   >             PendingDeprecationWarning,
   >             stacklevel=2,
   >         )
   >         api_key = os.environ.get('SENDGRID_API_KEY')
   >     sendgrid_client = sendgrid.SendGridAPIClient(api_key=api_key)
   >     response = 
sendgrid_client.client.mail.send.post(request_body=mail_data)
   >     # 2xx status code.
   >     if 200 <= response.status_code < 300:
   >         log.info(
   >             'Email with subject %s is successfully sent to recipients: %s',
   >             mail_data['subject'],
   >             mail_data['personalizations'],
   >         )
   >     else:
   >         log.error(
   >             'Failed to send out email with subject %s, status code: %s',
   >             mail_data['subject'],
   >             response.status_code,
   >         )
   >
   > —
   > You are receiving this because you authored the thread.
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/airflow/issues/18495#issuecomment-927951133>,
   > or unsubscribe
   > 
<https://github.com/notifications/unsubscribe-auth/ASQIG4TC5US2ZJHROYBROKLUECAIBANCNFSM5EV2FD7A>
   > .
   > Triage notifications on the go with GitHub Mobile for iOS
   > 
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
   > or Android
   > 
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
   >
   >
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to