I am developing my very first smarthome device - a doorbell. Please forgive me if my question may be naive.
Despite of all my attempts I am not able to send a “doorbell pressed event” to the Alexa event gateway and I am looking for help to understand what I am doing wrong or missing.
My Alexa Smarthome skill is active and linked to a Lambda function running in AWS; account linking using LWA is working fine and I can see my test doorbell device enabled in the Alexa app on my iphone.
When I enable my skill, Access.Grant is processed by the lambda function and returns this:
2020-10-21T23:34:30.071Z ee0e8aa8-8e1b-402b-9fae-f930dab7649e INFO Accept.Grant{ "directive": { "header": { "namespace": "Alexa.Authorization", "name": "AcceptGrant", "messageId": "5ebe87fa-3681-4796-9348-c954ea175314", "payloadVersion": "3" }, "payload": { "grant": { "type": "OAuth2.AuthorizationCode", "code": "RHynKUouKZlEALFMidMJ" }, "grantee": { "type": "BearerToken", "token": "Atza|IwEBIHHE5Xn9jfp5qPWlhBmLoqi24d09zPpnYglpwql2WyrGENgbg4dLU_4KtDnV6OoJLDo2CSTPHdlgyydKFeRgFatkGS_LsUJd_cIZKg1H7SWPnTIYSVOxzH1x_tb1Bi0vyxCmKD9tl_4sUwYRofR-1F6tjY_oCz5Q8apxUFiWR4FpnXo-IwHg5vLNoxj5_syej0Pyc8ra7mvIjXpjM4IlAE_F3LWlfui4fDJ1qEyFcVbFEqx6iI_nKGKfXw8GCcRbNi8USlN-skF8kvJUL1TIC3giyvuBSIXtMRA_8o-dSHC2SzJ0fHyPMDJerF6IKAZRxzb-h9UCRpTFaCzpK-l7_zuYJ2aDovoFl1_TxO-N0ZAdPmdPpoPf_h_dfH7cTdR23asmVXe5ubhfRxKjcfwL1Nnv" } } } }
I then try and POST a request to the event gateway to trigger the doorbell interaction using this command:
curl -i -XPOST --header 'Content-Type: application/json' --header 'Authorization: Bearer Atza|IwEBI...h2w' -d '@doorbell.json' https://api.eu.amazonalexa.com/v3/events
where the doorbell.json file is the following:
{ "context": {}, "event": { "header": { "messageId": "18b8e434-1872-445e-af1f-132deb4bb668", "namespace": "Alexa.DoorbellEventSource", "name": "DoorbellPress", "payloadVersion": "3" }, "endpoint": { "scope": { "type": "BearerToken", "token": "Atza|IwEBI...h2w" }, "endpointId": "belltest_id" }, "payload": { "cause": { "type": "PHYSICAL_INTERACTION" }, "timestamp": "2018-10-18T11:44:18.485Z" } } }
(the token has been shortened…)
… and I get the following response:
HTTP/2 401 content-type: application/json;charset=UTF-8 server: Server date: Thu, 22 Oct 2020 22:26:41 GMT x-amz-rid: 6CGECD650T7K9GQY2D62 access-control-allow-headers: authorization,x-amz-access-token access-control-allow-origin: * status: 401 x-amzn-requestid: 2a1dca7a-d290-4024-8392-f38ad620ed6c vary: Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent x-cache: Error from cloudfront via: 1.1 dd6d273a0e8062d5909bfd6bf570f52b.cloudfront.net (CloudFront) x-amz-cf-pop: MXP64-C1 x-amz-cf-id: Wtp34f6kfMcBW8qyudh1kIf9IBNkwGUgov5ZH4d2eazMZfOiphjpeA== { "header": { "namespace": "System", "name": "Exception", "messageId": "bd0c65f6-0873-4120-8ca3-1fe1bfd9a873" }, "payload": { "code": "INVALID_ACCESS_TOKEN_EXCEPTION", "description": "Access token is not valid." } }
I tried to disable and re-enable my skill and get a new access.grant and token, but the result is just always the same.
Can anybody help me find what I am doing wrong?
Thanks a lot!