当我尝试发送电子邮件时,收到错误:
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_API_KEY
env变量。我在开发环境中使用Mac OSX。我尝试按照你在文档中建议的那样设置env变量:
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env
当我在终端上键入echo $SENDGRID_API_KEY
时,它会显示一个空行。
答案 0 :(得分:0)
System.out.println(“API Key is”+ System.getenv(SENDGRID_API_KEY));