-
Notifications
You must be signed in to change notification settings - Fork 780
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
Setup issue #356
Comments
Hello @DonWono, Are you developing on Windows, Mac or Linux? |
Thanks for your quick reply. I'm developing on a Mac. When everything works I will be deploying to an Ubuntu server. |
What happens if you do the following from your command line: echo $SENDGRID_API_KEY If you don't see your API Key, try: export SENDGRID_API_KEY='YOUR_API_KEY'
echo $SENDGRID_API_KEY |
Hi @thinkingserious, var sg = require('sendgrid')(process.env.SENDGRID_API_KEY); I did a work around, and put the API_KEY into a JSON file and added the JSON file to gitignore. Thank you for your help. |
I'm having a similar issue when using a env variable. If I use the env variable I get the issue above. If I just drop the string into the require process it works. I can not figure out why. Works... Doesn't Work... Even if I log out the env and compare it to the string it's an exact match. |
Hello @thegregthomp, Your "Doesn't Work" case is failing because On a Unix-like system, this is usually done like this on the command line: export SENDGRID_API_KEY='YOUR_API_KEY' Then you can verify it works by executing the following on the command line: echo $SENDGRID_API_KEY To get your "Doesn't Work" case to work: SENDGRID_API_KEY=SG.iIpwjF6ASgmRuYmwl_KHoQ.EoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxY3NQ9vwd0
var sg = require('sendgrid')('SENDGRID_API_KEY'); But that is not recommended. We recommend you store your API Key in an environment variable for security reasons. I hope that helps. Thanks! |
This is an old issue but I was facing a similar issue and the problem was that I had 2 terminal windows open. One for installing packages and the other for running the server. The |
What's the solution to this if you're on windows? My issue may be different, as even with the key directly in place it still doesn't seem to work. I do know it's not accessing my api key properly when I use .env but I also get 'unresolved promise...' as well |
Are you setting it like this?
C:\> setx SENDGRID_API_KEY "YOUR_API_KEY"
Another way to provide environment variables to Node is to prepend the
environment variable on the command line:
SENDGRID_API_KEY=SG.xxx.yyyy node app.js
…On Thu, Nov 29, 2018 at 9:52 PM Drew Clements ***@***.***> wrote:
What's the solution to this if you're on windows? My issue may be
different, as even with the key directly in place it still doesn't seem to
work.
I do know it's not accessing my api key properly when I use .env but I
also get 'unresolved promise...' as well
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#356 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACL-svP5ufBQ__slqnDwyJmC_2rh7Cguks5u0LmdgaJpZM4L9ILb>
.
|
I ended up getting this resolved. My .env file was one level up in the
directory to where I was using sendgrid.
So I fought for 3 days because I was missing a '.'
I was using source ./sendgrid.env and needed source ../sendgrid.env
On Thu, Dec 6, 2018 at 5:17 PM Ashley Roach <[email protected]>
wrote:
… Are you setting it like this?
C:\> setx SENDGRID_API_KEY "YOUR_API_KEY"
Another way to provide environment variables to Node is to prepend the
environment variable on the command line:
SENDGRID_API_KEY=SG.xxx.yyyy node app.js
On Thu, Nov 29, 2018 at 9:52 PM Drew Clements ***@***.***>
wrote:
> What's the solution to this if you're on windows? My issue may be
> different, as even with the key directly in place it still doesn't seem
to
> work.
>
> I do know it's not accessing my api key properly when I use .env but I
> also get 'unresolved promise...' as well
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <
#356 (comment)
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/ACL-svP5ufBQ__slqnDwyJmC_2rh7Cguks5u0LmdgaJpZM4L9ILb
>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#356 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Aih_7oFC879FKsT4v6dWY4fXVVfBORN7ks5u2ZdzgaJpZM4L9ILb>
.
|
Oh bummer @drewclem but glad you figured it out! |
If you're a window user and getting source not recognized. |
Hi, I am still facing a 401 error from my python code. I have checked my environment variable is set properly as well. |
@MuhammadSufyanMalik Tracking here: sendgrid/sendgrid-python#561 |
Hi,
I'm trying to setup SendGrid, and I'm just following the instructions in the tutorial for "With Mail Helper Class". After I run the following code:
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env
I get an error "export: Command not found."
When I try to send my first send grid e-mail I get an error 401. 'The provided authorization grant is invalid, expired, or revoked.'
I've checked and echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env did create a sendgrid.env in my projects root folder.
When I checked the:
var sg = require('sendgrid')(process.env.SENDGRID_API_KEY);
console.log(sg);
The console returns Authorization: 'Bearer undefined',.
Any help would be appreciated. Thank you.
All the best,
Don
The text was updated successfully, but these errors were encountered: