Closed ghost closed 3 years ago
Hello @xiphos71,
Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at https://support.sendgrid.com.
Thank you!
SendGrid DX Team
Issue Summary
I began seeing 401 errors with my Python API integration tonight after I had it working Sept. 21. I've reissued API keys for myself to make sure that wasn't the issue, but still am seeing the error after integrating them into my environment.
Steps to Reproduce
Code Snippet
`import os from sendgrid import SendGridAPIClient from sendgrid.helpers.mail import Mail
message = Mail( from_email='root@SERVERNAME', to_emails='NUMBER@PROVIDER.com', subject='UPDATE REBOOT', html_content='SERVERNAME is going down for maintainance reboot. Please test.') try: sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY')) response = sg.send(message) print(response.status_code) print(response.body) print(response.headers) except Exception as e: print(e.message) `
Exception/Log
Traceback (most recent call last): File "./smtp-funsies.py", line 19, in
response = sg.send(message)
File "/home/xiphos/.local/lib/python3.6/site-packages/sendgrid/base_interface.py", line 62, in send
return self.client.mail.send.post(request_body=message)
File "/usr/local/lib/python3.6/site-packages/python_http_client/client.py", line 277, in http_request
self._make_request(opener, request, timeout=timeout)
File "/usr/local/lib/python3.6/site-packages/python_http_client/client.py", line 184, in _make_request
raise exc
python_http_client.exceptions.UnauthorizedError: HTTP Error 401: Unauthorized
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "./smtp-funsies.py", line 24, in
print(e.message)
AttributeError: 'UnauthorizedError' object has no attribute 'message'
Technical details:
What am I missing here?