Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.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
Azure 自动安装后创建SendGrid API密钥_Azure_Powershell_Sendgrid - Fatal编程技术网

Azure 自动安装后创建SendGrid API密钥

Azure 自动安装后创建SendGrid API密钥,azure,powershell,sendgrid,Azure,Powershell,Sendgrid,我创建了一个powershell脚本来自动安装Azure中的SendGrid帐户。一切正常。但是在安装完成后,我想创建一个API密钥,以便稍后在C#中使用它。不起作用。我尝试使用powershell发送此命令: curl-Uri”“-Method Post-Body'{“name”:“qnaapi键”,“scopes”:[“mail.send”]} 我得到以下错误: {“errors”:[{“field”:null,“message”:“需要授权”}]} 它似乎需要标题“authorizatio

我创建了一个powershell脚本来自动安装Azure中的SendGrid帐户。一切正常。但是在安装完成后,我想创建一个API密钥,以便稍后在C#中使用它。不起作用。我尝试使用powershell发送此命令:

curl-Uri”“-Method Post-Body'{“name”:“qnaapi键”,“scopes”:[“mail.send”]}

我得到以下错误: {“errors”:[{“field”:null,“message”:“需要授权”}]}

它似乎需要标题“authorization:Bearer”。 但在我的例子中,我的目标是创建这个键,因为以前没有创建过任何键

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

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

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

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

POST https://api.sendgrid.com/v3/public/tokens HTTP/1.1
Content-Type:application/json
{"username":"azure_04322409d13xxx@azure.com","password":"xxxxx"}

2.使用令牌创建api密钥

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

不再工作,因为现在SendGrid在使用用户名/密码身份验证时需要2FA。