自动安装后创建SendGrid API密钥

问题描述 投票:0回答:1

我创建了一个powershell脚本来自动在Azure中安装SendGrid帐户。一切都按预期工作。但是在安装完成后,我想创建一个API密钥,以便稍后在C#中使用它。 This不起作用。我试着用powershell发送这个命令:

curl -Uri“https://api.sendgrid.com/v3/api_keys”-Method Post -Body'{“name”:“QnA APi Key”,“scopes”:[“mail.send”]}'

我收到以下错误:{“errors”:[{“field”:null,“message”:“required required”}]}

它似乎需要标题'授权:承载<>'。但就我而言,我的目标是创建此密钥,因为之前没有人创建过。

当没有创建API密钥时,有人知道如何继续吗?

azure powershell sendgrid
1个回答
1
投票

当没有创建API密钥时,有人知道如何继续吗?

我们可以使用用户名和密码来获取令牌。使用令牌,我们可以创建SendGrid API密钥。

1.使用用户名和密码获取令牌

POST https://api.sendgrid.com/v3/public/tokens HTTP/1.1
Content-Type:application/json
{"username":"[email protected]","password":"xxxxx"}

enter image description here

2.使用令牌创建api密钥

Post https://api.sendgrid.com/v3/api_keys
Content-Type:application/json
Authorization: token e43xxxxxxxxxx38acf
{
"name":"xxxx",
"scopes":["mail.send"]
}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.