【问题标题】:SendGrid 401 Error - Java APISendGrid 401 错误 - Java API
【发布时间】:2018-04-01 22:30:43
【问题描述】:

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

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 环境变量设置不正确。我将 Mac OSX 用于我的开发环境。我尝试按照您在文档中的建议设置 env 变量:

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

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

【问题讨论】:

    标签: java macos environment-variables sendgrid


    【解决方案1】:

    System.out.println("API Key 是" + System.getenv(SENDGRID_API_KEY));

    【讨论】:

    • 提出的解决方案没有回答问题。
    猜你喜欢
    • 2022-10-20
    • 2020-08-24
    • 2017-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-25
    • 2016-11-21
    • 1970-01-01
    相关资源
    最近更新 更多