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)) 提出的解决方案没有回答这个问题。