我正在使用一个使用Alexa语音服务并维护不同用户的应用程序,因此用户需要使用亚马逊(LWA)登录.我已经实现了它,就像它是在文档中编写的,它可以完美地工作.
LWA docs:https://developer.amazon.com/de/docs/login-with-amazon/use-sdk-ios.html
AMZNAuthorizationManager.shared().authorize(request, withHandler: {(result : AMZNAuthorizeResult?, userDidCancel : Bool, error : Error?) -> () in
if error != nil {
// Handle errors from the SDK or authorization server.
}
else if userDidCancel {
// Handle errors caused when user cancels login.
}
else {
// Authentication was successful.
// Obtain the access token and user profile data.
self.accessToken = result!.token
self.user = result!.user!
}
})
Run Code Online (Sandbox Code Playgroud)
此外,我需要从DynamoDB检索信息,该信息使用Cognito进行身份验证.正如文档中所述,应该有一种方法将访问令牌从LWA传递给Cognito,但我找不到合适的位置.他们说LWA提供了AMZNAccessTokenDelegate,但它没有提供.委托方法提供Cognito需要的API结果.下面Cognito文档中的链接指的是我在上面发布的LWA文档中的完全相同的链接.
Cognito文档:https://docs.aws.amazon.com/cognito/latest/developerguide/amazon.html
func requestDidSucceed(apiResult: APIResult!) {
if …Run Code Online (Sandbox Code Playgroud) amazon-web-services ios amazon-cognito aws-sdk login-with-amazon
我目前正在努力将Amazon Alexa与我们当前的系统集成。我要做的TL; DR版本是,我应该能够通过Alexa Skill Management API以编程方式创建Alexa技能。
尽管这非常简单,但我在身份验证阶段遇到了障碍(涉及到“使用亚马逊登录”):
这应该起作用的方式是,您对SMAPI端点进行的每个请求都必须在AuthorizationHTTP标头中包含授权令牌。
假设我https://api.amazonalexa.com/v0/skills对此主体发出POST请求:
{
"vendorId":"my-vendor-id",
"skillManifest": {
"publishingInformation": {
"locales": {
"en-US": {
"summary": "This is a sample Alexa skill.",
"examplePhrases": [
"Alexa, open sample skill.",
"Alexa, turn on kitchen lights.",
"Alexa, blink kitchen lights."
],
"keywords": [
"Smart Home",
"Lights",
"Smart Devices"
],
"name": "Sample custom skill name.",
"description": "This skill has basic and advanced smart devices control features."
}
},
"isAvailableWorldwide": false,
"testingInstructions": "1) Say 'Alexa, discover my …Run Code Online (Sandbox Code Playgroud)