如何调试Alexa技能授权

How to debug Alexa skill authorization

我正在使用 Node red 实现智能家居 Alexa 技能。我遵循了一组教程 (tutorial)。但是,当我转到 link 帐户时,我得到了可怕的“我们此时无法 link”

我一直在很多地方来回寻找问题。以下是我目前已确认的内容:

  1. Alexa 应用程序能够打开我的身份验证 URL。
  2. 我可以授权并提供带有重定向的授权码 URL。
  3. Alexa 正在使用之前提供的授权代码请求访问令牌。
  4. 我能够使用访问令牌和刷新令牌验证授权代码和响应。

这是我用于重定向的内容 URL:

https://pitangui.amazon.com/api/skill/link/M186UMMFQ858RV?state=A2SAAEAEBw-F8TfUcH6ibqpm0e4UaoB8HKegd9HwuI1WKiS6r6p7i2YcPhi_zUUxShCH6Gf5EcSDpJU9gjNcb2KAyL5ed6HWlgU5owQberP1Pk_gPeQmZon6wD_r9PHxWWb-RDpER66U1LUA7UgmRXdLBsiDnFaODdXmUgonCVIn9tIXdrMUkEAJhwtCrGo_Ku11kfHMEPBSSNoAjntq2prtsQ_43Y7kJ-8J1fDEOG7-41LdC_r_A67Y0EDWllDQ2EQLxVM_mqWUGV2hE1baymi1N2JaxrGqKQo3nzkE65KtGORa6uRVQ0vcbCsv6IeBpYIQnzgpjqu6yfA5CTNSxaCzRlKy_pkWmnr69kZjQHYVr8grlrRdCC4T9EPUCYFNrpi07-geDGefvOZDm2yMGjWmDlaB_KIjSBBIIAtJDFDesTm0UFP1vu2QsbakQorrqh5DqPm1VLkNwEmYFBajpWzmbvwHLb15nznkeqGe8fWPeV1hGOhlUrhMtKTSbXfse6dl_t_U3BqwWdNqpAjCEzCaYleyEjRzIMNQLlXK_3n079Jhqiox90qwYb3JkdUjuM3t3EnFOg3xIq1Fcrz0TTPMrLPdLPvql0kP5dPFQnw0tzbjuZn5ftAyihnYWTwvzl64RG8X0H2mjYoGGAdFJ_MpPtSYXkxG1eQg6Q_8d3YKR8M434AOLQ&code=DmhRCJ1Uw7pjpd8U3xyV36F6ZU9zjnf1itcmw7qywbfF

我按照这些教程来帮助调试问题:

Alexa debugging Tutorial

Setting up Cloud Formation

对于云形成一,我能够验证我能够正确生成令牌。

另外,我和这个人有一个非常相似的问题: Alexa, Unable to link your skill

有没有人可以帮助我解决这个问题?有什么方法可以设置云手表来记录 Alexa 技能身份验证以确认该技能正在获取正确的访问令牌吗?

注意:这是我的应用程序调试日志的完整列表:

1:04:45 PM - [debug] [alexa-adapter:Alexa] oauth_get
1:04:45 PM - [debug] [alexa-adapter:Alexa] oauth_get CCHI {"client_id":"https://pitangui.amazon.com/","response_type":"code","state":"A2SAAEAEBw-F8TfUcH6ibqpm0e4UaoB8HKegd9HwuI1WKiS6r6p7i2YcPhi_zUUxShCH6Gf5EcSDpJU9gjNcb2KAyL5ed6HWlgU5owQberP1Pk_gPeQmZon6wD_r9PHxWWb-RDpER66U1LUA7UgmRXdLBsiDnFaODdXmUgonCVIn9tIXdrMUkEAJhwtCrGo_Ku11kfHMEPBSSNoAjntq2prtsQ_43Y7kJ-8J1fDEOG7-41LdC_r_A67Y0EDWllDQ2EQLxVM_mqWUGV2hE1baymi1N2JaxrGqKQo3nzkE65KtGORa6uRVQ0vcbCsv6IeBpYIQnzgpjqu6yfA5CTNSxaCzRlKy_pkWmnr69kZjQHYVr8grlrRdCC4T9EPUCYFNrpi07-geDGefvOZDm2yMGjWmDlaB_KIjSBBIIAtJDFDesTm0UFP1vu2QsbakQorrqh5DqPm1VLkNwEmYFBajpWzmbvwHLb15nznkeqGe8fWPeV1hGOhlUrhMtKTSbXfse6dl_t_U3BqwWdNqpAjCEzCaYleyEjRzIMNQLlXK_3n079Jhqiox90qwYb3JkdUjuM3t3EnFOg3xIq1Fcrz0TTPMrLPdLPvql0kP5dPFQnw0tzbjuZn5ftAyihnYWTwvzl64RG8X0H2mjYoGGAdFJ_MpPtSYXkxG1eQg6Q_8d3YKR8M434AOLQ","scope":"smart_home","redirect_uri":"https://pitangui.amazon.com/api/skill/link/M186UMMFQ858RV"}
16 Dec 13:04:45 - [error] [alexa-adapter:Alexa] oauth_get login
1:05:18 PM - [debug] [alexa-adapter:Alexa] oauth_get
1:05:18 PM - [debug] [alexa-adapter:Alexa] oauth_get CCHI {"code":"ANpoNSSqiwPvRhEzrZDe","scope":"profile"}
16 Dec 13:05:18 - [error] [alexa-adapter:Alexa] oauth_get profile
1:05:18 PM - [debug] [alexa-adapter:Alexa] manage_login_with_amazon_access_token
1:05:18 PM - [debug] [alexa-adapter:Alexa] manage_login_with_amazon_access_token CCHI config {"id":"b6996b92647b12f3","type":"alexa-adapter","name":"Alexa","http_path":"alexa","login_with_amazon":true,"event_endpoint":"https://api.amazonalexa.com/v3/events","scope":"smart_home","emails":["***@gmail.com"],"msg_check":false,"verbose":true,"port":"","_users":["47c54cce05a7162a","9d730dee04a484b7"]}
1:05:18 PM - [debug] [alexa-adapter:Alexa] manage_login_with_amazon_access_token CCHI credentials {"your_client_id":"https://pitangui.amazon.com/","your_secret":"supersercetpassword","oa2_client_id":"amzn1.application-oa2-client.9283145f821e458097564e6bbbd8aabb","oa2_secret":"44ef5c74c58333e58a9f7a6cdc2246df413236ecbcd100170c4935d04d12001e","skill_client_id":"amzn1.application-oa2-client.56b9c72428544026a6e419b0c9d23a39","skill_secret":"a7a0b690c8b1a43e890bd2c6f26463551ba430919ec298de08ed1a58623c3fb2"}
1:05:18 PM - [debug] [alexa-adapter:Alexa] get_access_token lwa
1:05:18 PM - [debug] [alexa-adapter:Alexa] get_access_token request with code
1:05:18 PM - [debug] [alexa-adapter:Alexa] get_access_token request {"grant_type":"authorization_code","code":"ANpoNSSqiwPvRhEzrZDe","redirect_uri":"https://alexatest2.ddns.net/alexa/oauth"}
1:05:19 PM - [debug] [alexa-adapter:Alexa] CCHI get_access_token res {"req":{"method":"POST","url":"https://api.amazon.com/auth/o2/token","data":{"grant_type":"authorization_code","code":"ANpoNSSqiwPvRhEzrZDe","redirect_uri":"https://alexatest2.ddns.net/alexa/oauth"},"headers":{"user-agent":"node-superagent/3.8.3","content-type":"application/x-www-form-urlencoded","authorization":"Basic YW16bjEuYXBwbGljYXRpb24tb2EyLWNsaWVudC45MjgzMTQ1ZjgyMWU0NTgwOTc1NjRlNmJiYmQ4YWFiYjo0NGVmNWM3NGM1ODMzM2U1OGE5ZjdhNmNkYzIyNDZkZjQxMzIzNmVjYmNkMTAwMTcwYzQ5MzVkMDRkMTIwMDFl"}},"header":{"server":"Server","date":"Thu, 16 Dec 2021 18:05:18 GMT","content-type":"application/json;charset=UTF-8","content-length":"934","connection":"close","x-amz-rid":"KSRNMHVJFR2WDD82ZZXK","x-amzn-requestid":"72fdeb72-9f1a-4d41-a5a6-463b09523c73","x-amz-date":"Thu, 16 Dec 2021 18:05:18 GMT","cache-control":"no-cache, no-store, must-revalidate","pragma":"no-cache","vary":"Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent","permissions-policy":"interest-cohort=()"},"status":200,"text":"{\"access_token\":\"Atza|IwEBIDC8t8KapoVU4h_1UfNJesOXwKQc9t8TpzdMAVzOrHlwBgEEWWQ0oq_hMdYf9saAW-1Kb5uP9A22rwiHt_qPWy3jPr7oeD-A-3JeDj5YhlFp_ROdnPREkwsYMdsyj0i7EqbhKM_pIbqJUjgi1F9lfs7--CqtgXd8ZW7xDXAFniF83w2enPmkNnyxgmTOSQSuYSKhX_k0uXhFZ0eIj79le2xFC7XbfGs6eBqokwHmiyIibYhMmcZ6NrQftSV1bKEGhR2n3HMUfWFsln__h2mF9ZaL19I2d4igDfvozelOjO0bb_tfH5WN1dQTiLDADXSbVHHRufc-e1WCSSOvWOEpizPtMWGQLvmLjU9Ta0bWlJGCMojqVciKGyQEDhq-xtIvrmnI2QYFW1bLDUpdDxvplqm-E02hf_f3dX0UUq4oL0b4zA\",\"refresh_token\":\"Atzr|IwEBIFXkwDQ6A3fNorMBzdRpINRei2WS4ZZ12XQG5n5LX6lj0AxdY2_LBT9TTFJ6vAX1hZw1PB9otGpk6jlH5XshSMJMQAUn4Q5YDtAtDoz3Z-0Hx77H5H91eoTq0hx4d_lHr7i45O7tQdOcaWao-JewfgZjurdxPKa6Q8933cg9MX-HEoylognvpvsitpvG_hbFTnv5hBl6Jeg1nSyaU6S-9kKkmn5BjmtgoP1HIneRymWxX-GZFoPKFGnhS40iOUaA8nuppvglpNsqxKcLhhKrDcTXERXekPxfg_0tLnL8Lzaz_zXdD9JFzHZgsjqj-9sPootCShyGORc-FCgqWo7eFmzxakhw-PZlRqrKmqSPElMqY7i-ptm_f2Wwq4BRWN6XsAQC3Oph4iKhhhzkf0ElxTxm\",\"token_type\":\"bearer\",\"expires_in\":3600}"}
1:05:19 PM - [debug] [alexa-adapter:Alexa] writeJson: tokens
1:05:19 PM - [debug] [alexa-adapter:Alexa] writeJson: filename /home/pi/.node-red/alexa-tokens_b6996b92647b12f3.json
1:05:19 PM - [debug] [alexa-adapter:Alexa] writeJson: tokens saved
1:05:19 PM - [debug] [alexa-adapter:Alexa] get_access_token tokens lwa saved
1:05:19 PM - [debug] [alexa-adapter:Alexa] mlwaat get_access_token CCHI res Atza|IwEBIDC8t8KapoVU4h_1UfNJesOXwKQc9t8TpzdMAVzOrHlwBgEEWWQ0oq_hMdYf9saAW-1Kb5uP9A22rwiHt_qPWy3jPr7oeD-A-3JeDj5YhlFp_ROdnPREkwsYMdsyj0i7EqbhKM_pIbqJUjgi1F9lfs7--CqtgXd8ZW7xDXAFniF83w2enPmkNnyxgmTOSQSuYSKhX_k0uXhFZ0eIj79le2xFC7XbfGs6eBqokwHmiyIibYhMmcZ6NrQftSV1bKEGhR2n3HMUfWFsln__h2mF9ZaL19I2d4igDfvozelOjO0bb_tfH5WN1dQTiLDADXSbVHHRufc-e1WCSSOvWOEpizPtMWGQLvmLjU9Ta0bWlJGCMojqVciKGyQEDhq-xtIvrmnI2QYFW1bLDUpdDxvplqm-E02hf_f3dX0UUq4oL0b4zA
1:05:19 PM - [debug] [alexa-adapter:Alexa] get_user_profile CCHI access_token res {"access_token":"Atza|IwEBIDC8t8KapoVU4h_1UfNJesOXwKQc9t8TpzdMAVzOrHlwBgEEWWQ0oq_hMdYf9saAW-1Kb5uP9A22rwiHt_qPWy3jPr7oeD-A-3JeDj5YhlFp_ROdnPREkwsYMdsyj0i7EqbhKM_pIbqJUjgi1F9lfs7--CqtgXd8ZW7xDXAFniF83w2enPmkNnyxgmTOSQSuYSKhX_k0uXhFZ0eIj79le2xFC7XbfGs6eBqokwHmiyIibYhMmcZ6NrQftSV1bKEGhR2n3HMUfWFsln__h2mF9ZaL19I2d4igDfvozelOjO0bb_tfH5WN1dQTiLDADXSbVHHRufc-e1WCSSOvWOEpizPtMWGQLvmLjU9Ta0bWlJGCMojqVciKGyQEDhq-xtIvrmnI2QYFW1bLDUpdDxvplqm-E02hf_f3dX0UUq4oL0b4zA"}
1:05:19 PM - [debug] [alexa-adapter:Alexa] get_user_profile CCHI profile res {"req":{"method":"GET","url":"https://api.amazon.com/user/profile","headers":{"user-agent":"node-superagent/3.8.3","authorization":"Bearer Atza|IwEBIDC8t8KapoVU4h_1UfNJesOXwKQc9t8TpzdMAVzOrHlwBgEEWWQ0oq_hMdYf9saAW-1Kb5uP9A22rwiHt_qPWy3jPr7oeD-A-3JeDj5YhlFp_ROdnPREkwsYMdsyj0i7EqbhKM_pIbqJUjgi1F9lfs7--CqtgXd8ZW7xDXAFniF83w2enPmkNnyxgmTOSQSuYSKhX_k0uXhFZ0eIj79le2xFC7XbfGs6eBqokwHmiyIibYhMmcZ6NrQftSV1bKEGhR2n3HMUfWFsln__h2mF9ZaL19I2d4igDfvozelOjO0bb_tfH5WN1dQTiLDADXSbVHHRufc-e1WCSSOvWOEpizPtMWGQLvmLjU9Ta0bWlJGCMojqVciKGyQEDhq-xtIvrmnI2QYFW1bLDUpdDxvplqm-E02hf_f3dX0UUq4oL0b4zA","content-type":"application/x-www-form-urlencoded;charset=UTF-8","accept":"application/json"}},"header":{"server":"Server","date":"Thu, 16 Dec 2021 18:05:19 GMT","content-type":"application/json;charset=UTF-8","content-length":"115","connection":"close","x-amz-rid":"G7V58QBWQ1EXQP2FQ7JT","x-amzn-requestid":"dec61b8d-4116-41a1-acc2-44f17cb86412","x-amz-date":"Thu, 16 Dec 2021 18:05:19 GMT","content-language":"en-US","vary":"Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent","permissions-policy":"interest-cohort=()"},"status":200,"text":"{\"user_id\":\"amzn1.account.AGBCE2ITIGEQNHWMFIRL6QFU3DVQ\",\"name\":\"***\",\"email\":\"***@gmail.com\"}"}
1:05:19 PM - [debug] [alexa-adapter:Alexa] get_user_profile CCHI res {"user_id":"amzn1.account.AGBCE2ITIGEQNHWMFIRL6QFU3DVQ","name":"***","email":"***@gmail.com"}
1:05:19 PM - [debug] [alexa-adapter:Alexa] ***@gmail.com OK
16 Dec 13:05:19 - [error] [alexa-adapter:Alexa] Username ***@gmail.com authorized
1:05:19 PM - [debug] [alexa-adapter:Alexa] manage_login_with_amazon_access_token CCHI auth_code {"code":"DmhRCJ1Uw7pjpd8U3xyV36F6ZU9zjnf1itcmw7qywbfF","expire_at":1639678039557}
1:05:19 PM - [debug] [alexa-adapter:Alexa] redirect_to_amazon to https://pitangui.amazon.com/api/skill/link/M186UMMFQ858RV?state=A2SAAEAEBw-F8TfUcH6ibqpm0e4UaoB8HKegd9HwuI1WKiS6r6p7i2YcPhi_zUUxShCH6Gf5EcSDpJU9gjNcb2KAyL5ed6HWlgU5owQberP1Pk_gPeQmZon6wD_r9PHxWWb-RDpER66U1LUA7UgmRXdLBsiDnFaODdXmUgonCVIn9tIXdrMUkEAJhwtCrGo_Ku11kfHMEPBSSNoAjntq2prtsQ_43Y7kJ-8J1fDEOG7-41LdC_r_A67Y0EDWllDQ2EQLxVM_mqWUGV2hE1baymi1N2JaxrGqKQo3nzkE65KtGORa6uRVQ0vcbCsv6IeBpYIQnzgpjqu6yfA5CTNSxaCzRlKy_pkWmnr69kZjQHYVr8grlrRdCC4T9EPUCYFNrpi07-geDGefvOZDm2yMGjWmDlaB_KIjSBBIIAtJDFDesTm0UFP1vu2QsbakQorrqh5DqPm1VLkNwEmYFBajpWzmbvwHLb15nznkeqGe8fWPeV1hGOhlUrhMtKTSbXfse6dl_t_U3BqwWdNqpAjCEzCaYleyEjRzIMNQLlXK_3n079Jhqiox90qwYb3JkdUjuM3t3EnFOg3xIq1Fcrz0TTPMrLPdLPvql0kP5dPFQnw0tzbjuZn5ftAyihnYWTwvzl64RG8X0H2mjYoGGAdFJ_MpPtSYXkxG1eQg6Q_8d3YKR8M434AOLQ&code=DmhRCJ1Uw7pjpd8U3xyV36F6ZU9zjnf1itcmw7qywbfF
1:05:20 PM - [debug] [alexa-adapter:Alexa] token_post
1:05:20 PM - [debug] [alexa-adapter:Alexa] token_post CCHI {"grant_type":"authorization_code","code":"DmhRCJ1Uw7pjpd8U3xyV36F6ZU9zjnf1itcmw7qywbfF","client_id":"https://pitangui.amazon.com/","redirect_uri":"https://pitangui.amazon.com/api/skill/link/M186UMMFQ858RV","client_secret":"supersercetpassword"}
16 Dec 13:05:20 - [error] [alexa-adapter:Alexa] token_post authorization_code
1:05:20 PM - [debug] [alexa-adapter:Alexa] writeJson: tokens
1:05:20 PM - [debug] [alexa-adapter:Alexa] writeJson: filename /home/pi/.node-red/alexa-tokens_b6996b92647b12f3.json
1:05:20 PM - [debug] [alexa-adapter:Alexa] writeJson: tokens saved
1:05:20 PM - [debug] [alexa-adapter:Alexa] token_post save_tokens ok
1:05:20 PM - [debug] [alexa-adapter:Alexa] Returns tokens
1:05:20 PM - [debug] [alexa-adapter:Alexa] Returns tokens {"access_token":"Atza|2JQkP9TKfKD6nCLjHaB8MH8RuWCnJSrifYWfMdkd1zob","token_type":"bearer","expires_in":3600,"refresh_token":"Atzr|DAkB4wn4RttcSEFv8yA3XNyqbTfSHMy9p152EKqgjGiv"}
1:05:20 PM - [debug] [alexa-adapter:Alexa] smarthome_post
1:05:20 PM - [debug] [alexa-adapter:Alexa] smarthome_post CCHI {"directive":{"header":{"namespace":"Alexa.Authorization","name":"AcceptGrant","messageId":"ef50735b-c3ab-4de1-a773-eb509497dc1d","payloadVersion":"3"},"payload":{"grant":{"type":"OAuth2.AuthorizationCode","code":"ANHiAPOFhqosejPesiXS"},"grantee":{"type":"BearerToken","token":"Atza|2JQkP9TKfKD6nCLjHaB8MH8RuWCnJSrifYWfMdkd1zob"}}}}
1:05:20 PM - [debug] [alexa-adapter:Alexa] CCHI received directive "Alexa.Authorization" "AcceptGrant" undefined
16 Dec 13:05:20 - [error] [alexa-adapter:Alexa] smarthome_post: oauth_get AcceptGrant
1:05:20 PM - [debug] [alexa-adapter:Alexa] accept_grant
1:05:20 PM - [debug] [alexa-adapter:Alexa] get_access_token evn
1:05:20 PM - [debug] [alexa-adapter:Alexa] get_access_token request with code
1:05:20 PM - [debug] [alexa-adapter:Alexa] get_access_token request {"grant_type":"authorization_code","code":"ANHiAPOFhqosejPesiXS","redirect_uri":"https://alexatest2.ddns.net/alexa/oauth"}
1:05:21 PM - [debug] [alexa-adapter:Alexa] CCHI get_access_token res {"req":{"method":"POST","url":"https://api.amazon.com/auth/o2/token","data":{"grant_type":"authorization_code","code":"ANHiAPOFhqosejPesiXS","redirect_uri":"https://alexatest2.ddns.net/alexa/oauth"},"headers":{"user-agent":"node-superagent/3.8.3","content-type":"application/x-www-form-urlencoded","authorization":"Basic YW16bjEuYXBwbGljYXRpb24tb2EyLWNsaWVudC41NmI5YzcyNDI4NTQ0MDI2YTZlNDE5YjBjOWQyM2EzOTphN2EwYjY5MGM4YjFhNDNlODkwYmQyYzZmMjY0NjM1NTFiYTQzMDkxOWVjMjk4ZGUwOGVkMWE1ODYyM2MzZmIy"}},"header":{"server":"Server","date":"Thu, 16 Dec 2021 18:05:21 GMT","content-type":"application/json;charset=UTF-8","content-length":"656","connection":"close","x-amz-rid":"4FVHGBW1GRA8YJG7A1BS","x-amzn-requestid":"df3f2684-48ac-41eb-9bc7-3fba070565c4","x-amz-date":"Thu, 16 Dec 2021 18:05:21 GMT","cache-control":"no-cache, no-store, must-revalidate","pragma":"no-cache","vary":"Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent","permissions-policy":"interest-cohort=()"},"status":200,"text":"{\"access_token\":\"Atza|IwEBIGjTdoxblOzOBFZ0CkwR7q2PSirJXBr74oQnCUXfpaWcqT8dy81Be4V2bbbraVApl7FTDAzO-wd-jIjDmNX-bjYuYcwQcjr1VwY3VJIj2W6RAt40KqWUQPexs0cZZEl1rH9E62tW4Otw_2oWuN8gmcnQDtiBjk8MXFpWfzI6JCESvX5oPYE8kwGG1CFue9eDoUDZ10xDFJ61LQiZbeMA_E5VMxH6rdbedF2oCr1ADo7HvUQALvkCr4EN3JP_m0pNp9Hzvu8SNZLFOnqu8SJ7o8da\",\"refresh_token\":\"Atzr|IwEBIHxNtAXphsdL0K2xRqpEoGcMcT_S5i5QJTJN5RTyVX5T_J8rT7ZEnOBwWdaTE_IZm49ZdIcv68ejgzUsnsWsXBK2RwP0TqS9PX15pncd3VTVorudXNavi3W4A2p8QIueLrAi8QY8zlSmf-6FzV0ypMQr9UKdNGqy4Y2HgYc5xkipZExjff0Cd64tmoo0-Chaw1n8Oin6XGm3vgOvfKvVJUOl9TReihe2P94Hx_mBYQAPk-JEg8MmAMvFh17bt6bhDQ4wrqea1adfVILKvOPwvqVG\",\"token_type\":\"bearer\",\"expires_in\":3600}"}
1:05:21 PM - [debug] [alexa-adapter:Alexa] writeJson: tokens
1:05:21 PM - [debug] [alexa-adapter:Alexa] writeJson: filename /home/pi/.node-red/alexa-tokens_b6996b92647b12f3.json
1:05:21 PM - [debug] [alexa-adapter:Alexa] writeJson: tokens saved
1:05:21 PM - [debug] [alexa-adapter:Alexa] get_access_token tokens evn saved
1:05:21 PM - [debug] [alexa-adapter:Alexa] accept_grant tokens evn OK

好吧,我撒谎了。这不完全是一个 t。我为自定义命令启用了一项设置。有了这个,我需要建立技能,以便能够注册帐户。请在此处查看此帖子:

Build Skill