Skip to content

apikey-attribute in SendGridAPIClient.__init__() rendered useless by commit 1ee10fda132e132ca99ddcc7ff7149cebc4d96a2 #197

@johguse

Description

@johguse

Commit 1ee10fd introduced support for v2 api_key naming and tries to fetch the api_key attribute if available. If self._apikey has already been set by the apikey attribute then self._apikey will be overwritten with a (possibly non-existing) environment variable when api_key is missing. This results in a 401 Unauthorized response from Sendgrid as no API-key is present.

To reproduce remove enviroment variable for key and set it directly when constructing SendGridAPIClient:
mySendGrid = sendgrid.SendGridAPIClient(apikey="THISISMYKEY)

The above does not work however the following with v2 naming works and serves as a work-around:
mySendGrid = sendgrid.SendGridAPIClient(api_key="THISISMYKEY)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions