I am using Flask Ask to develop my Alexa Skill. I want to give different permissions to different Users. For this I have to access the UserID. I have been searching for days now. I have read documentation of Flask Ask and there was not sufficient information about accessing UserID.
Asked
Active
Viewed 708 times
-1
-
[It's in their full documentation](https://alexatutorial.com/flask-ask/requests.html). `UserId` is found inside a `session` object. – spicypumpkin Apr 25 '17 at 20:30
-
I have gone through this documentation. It does not return any thing when I use 'uid = session.user.userId' infact it returns an error AttributeError: 'NoneType' object has no attribute 'session' – M HümZå Ãwâñ Apr 26 '17 at 09:39
-
and when i try to return `question(session.user.userId)` it gives internal error 500 on my Alexa test tab – M HümZå Ãwâñ Apr 27 '17 at 08:09
1 Answers
1
According to the amazon dev documentation for the Request Format : "Standard request types (LaunchRequest, IntentRequest, and SessionEndedRequest) include the session object.
Requests from interfaces such as AudioPlayer and PlaybackController are not sent in the context of a session, so they do not include the session object. The context.System.user and context.System.application objects provide the same user and application information as the same objects within session – see Context Object."
So I guess you are not using a standard request. Thus, you need to access the userId from the context object. The documentation for flask-ask has been updated to explain how to access that.
In short, you should do this:
from flask_ask import context
uid = context.System.user.userId

mc51
- 1,883
- 14
- 28