Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SendGrid 401错误-Java API_Java_Macos_Environment Variables_Sendgrid - Fatal编程技术网

SendGrid 401错误-Java API

SendGrid 401错误-Java API,java,macos,environment-variables,sendgrid,Java,Macos,Environment Variables,Sendgrid,当我尝试发送电子邮件时,我收到错误: Request returned status Code 401Body:{"errors":[{"message":"The provided authorization grant is invalid, expired, or revoked","field":null,"help":null}]} 当我尝试 System.out.println("API Key is " + System.getenv("SENDGRID_API_KEY"));

当我尝试发送电子邮件时,我收到错误:

Request returned status Code 401Body:{"errors":[{"message":"The provided authorization grant is invalid, expired, or revoked","field":null,"help":null}]}
当我尝试

System.out.println("API Key is " + System.getenv("SENDGRID_API_KEY"));
我明白了

API Key is null
因此,显然
SENDGRID\u API\u KEY
env变量设置不正确。我正在为我的开发环境使用MacOSX。我试图按照您在文档中的建议设置env变量:

echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env

当我在终端上键入echo$SENDGRID_API_KEY时,它会显示一个空行。

System.out.println(“API KEY is”+System.getenv(SENDGRID_API_KEY))

提出的解决方案没有回答这个问题。