【发布时间】:2018-12-18 12:42:47
【问题描述】:
我想为我的 Alexa Devide 创建推送通知。由于推送通知程序已关闭,我正在尝试创建提醒。最后的想法是使用此代码创建一个 Azure 函数,并在 TFS 构建失败时调用。
我在控制台应用程序中使用 Alexa.NET 和 Alexa.NET.Reminders,在 Alexa 门户和移动应用程序中已经拥有和 Alexa Skill 以及授予的所有权限。
一切似乎都很好,直到我尝试阅读我帐户中的提醒,当出现异常“Invalid Bearer Token”时
这是代码:
[Fact]
public async Task SendNotificationTest()
{
var clientId = "xxxx";
var clientSecret = "yyyy";
var alexaClient = clientId;
var alexaSecret = clientSecret;
var accessToken = new Alexa.NET.AccessTokenClient(Alexa.NET.AccessTokenClient.ApiDomainBaseAddress);
var token = await accessToken.Send(alexaClient, alexaSecret);
var reminder = new Reminder
{
RequestTime = DateTime.UtcNow,
Trigger = new RelativeTrigger(12 * 60 * 60),
AlertInformation = new AlertInformation(new[] { new SpokenContent("test", "en-GB") }),
PushNotification = PushNotification.Disabled
};
var total = JsonConvert.SerializeObject(reminder);
var client = new RemindersClient("https://api.eu.amazonalexa.com", token.Token);
var alertList = await client.Get();
foreach (var alertInformation in alertList.Alerts)
{
Console.WriteLine(alertInformation.ToString());
}
try
{
var response = await client.Create(reminder);
}
catch (Exception ex)
{
var x = ex.Message;
}
}
有没有获取访问令牌的示例? 我错过了这个过程中的一个步骤吗?
提前致谢。
【问题讨论】:
标签: c# alexa alexa-skills-kit alexa-skill