Chris avatar image
Chris asked

User Id is missing

I have a developer account and smart home skill that has been around for about 3 years which is only used for my house, so only one account is linked to it. Up till now I didn't have any reason to send out of session/asynchronous messages, so even though the skill is using account linking I didn't pay much attention to the user id. Now I have a need to send asynchronous messages and I need the user id to send those messages. Note I'm using a Python script in AWS Lambda for the skill code.

The skill is account linked using Login with Amazon.

The documentation says that the user id should be in the context sent to function handling the event, but the user id field (or value) isn't in the context or request variables passed into the event handler function.

The user's token that was given in the grant request is provided on every request, so if the problem was identifying the user, I could just use that, but my goal is to send asynchronous messages and according to this documentation I need the user id for that.

If there is a way to get the user id from the user's token, then maybe I could go that way (I would prefer HTTP/URL method).

Below is a discover request:

{'directive': {'header': {'namespace': 'Alexa.Discovery', 'name': 'Discover', 'payloadVersion': '3', 'messageId': '816ea9a0-0ba0-4538-8c8d-f5455b157e0f'}, 'payload': {'scope': {'type': 'BearerToken', 'token': 'Atza|IwEBIKT5Z-rLJgSWzJ9-qshILOCkhvhcNz5v6ZDsiXT6pb7JVereyh6wqAon_yTn-i4N3yiINbMsc_TwEVsi066dvpLDZ1t14qqNvIYuUujhDfj9YMUJWkn43d1J3qinjhUCukLruTf6T4HyzjFYnaWF5GIj5AomZWlfRSsli5mJ2IdEzyAXbcSNK7-uiPUEV_8Bszi0w8C5J-No1KkYGz5FI4wbPf8QdJOeV8yA-9u000_nLy6vX5nrgr6YGSvfNgAE1rTjjVRcRvr7xshXyqsnFePU-_mADktsdB_maa_DL_4Ro7upBcwoBYJd4NWybZzGMmxkuGMErgxtAuzAp0sBPKMUkSWR5KSe9zZMJiQ_xT4GIDT5DpjU3oGKLPA2VbaoDDOw0dHcmxH2RhVoACzjQwd0'}}}}

And the context:


The code that generated these printouts:

def lambda_handler(request, context):

Seeing the Cognito information in there I thought that maybe because long ago I tried using it instead of Login with Amazon that might be the problem even though have long deleted any of the Cognito domains and pools.

So, I created another skill and copied over the same code to try it.

The request data was basically the same (just changed token information and such), but the context is essentially empty.


{'directive': {'header': {'namespace': 'Alexa.Discovery', 'name': 'Discover', 'payloadVersion': '3', 'messageId': 'aef608bd-accc-47ed-8c71-da04522163ec'}, 'payload': {'scope': {'type': 'BearerToken', 'token': 'Atza|IwEBICgXU6m6wqj4yigfbwKGlVt9pCmqQWyz47fa90SB5pYCxsZ-U38ZWdvwPXu6CJrUcij_64Niurj1rY7dLjm3CFkOX8EZuaBcbVqio0IlaEwf_pyRP-HuJYY1PWY7OykhM8h4usqPbJPrp7uA0JzWkVQFFXqRSdGDMaDESbStvtihvgBz7-Dgp8QabMp8qM8GW8aBUU1rOjIEyM-bIaNAGokQdbeExU2e4iyNNsp6V3NiwBYMTKtzIzEalO-54Kn1CivOF23PX4P_rzznc9K2HLab8kS792_MMgtq_rjDkR47-C_Sgymkcu3T-o_FTyaBjzsflhDKLD8gEPIJU2XCrSncZunK9BRwsovYwHty3nKS9ih8l2qFfmWR9XyjSDwU1vc'}}


<__main__.LambdaContext object at 0x7f695d449b2

Thank you for anything you can suggest.


alexa smart homeuserid
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers