Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix issue with new client overriding previously set api key #1305

Merged
merged 1 commit into from
Sep 29, 2021
Merged

test: fix issue with new client overriding previously set api key #1305

merged 1 commit into from
Sep 29, 2021

Conversation

seantcanavan
Copy link
Contributor

@seantcanavan seantcanavan commented Sep 27, 2021

I was using the tests as informal documentation so I wasn't sure whether to use the test or the doc tag but since I haven't modified any test output I'm going with doc as it applies more closely to how I was interpreting the code.

if you call sgMail.setClient() before you call sgMail.setApiKey() then everything is great. If you call them in the order that this test does you'll forever get Unauthorized 401 section with data.headers in node_modules/@sendgrid/client/src/classes/client.js createRequest() function not including Bearer Authorization <<YOUR_API_KEY>>

This issue is reproducible whether you set the client / key at the top outside of a typescript class, inside the typescript class' constructor, or inside the function right before the sgMail.send call.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

Here's a GIF of the issue:
set_client_order_matters

if you call `sgMail.setClient()` _before_ you call `sgMail.setApiKey()` then everything is great. If you call them in the order that this test does you'll forever get `Unauthorized` 401 section with data.headers not including `Bearer Authorization <<YOUR_API_KEY>>`
@shwetha-manvinkurke shwetha-manvinkurke changed the title doc: fix issue with new client overriding previously set api key test: fix issue with new client overriding previously set api key Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants