pythonapiaccess-tokenalexa-skills-kitask-cli

name 'REQUIRED_PERMISSIONS' is not defined


I am trying to setup a voice permission via alexa for a timer with the following code:

class LaunchRequestHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
    return ask_utils.is_request_type("LaunchRequest")(handler_input),ask_utils.is_request_type("AMAZON.YesIntent")(handler_input), ask_utils.is_request_type("AMAZON.NoIntent")(handler_input)

def handle(self, handler_input):
    permissions = handler_input.request_envelope.context.system.user.permissions
    if not (permissions and permissions.consent_token):
        return (
            handler_input.response_builder
            .speak("Please give permissions to set timers using the alexa app.")
            .set_card(
                AskForPermissionsConsentCard(permissions=REQUIRED_PERMISSIONS)
            )
            .response
        )

However, I am getting name 'REQUIRED_PERMISSIONS' is not defined The weird thing is that it is working perfectly with my other skill but not with the new skill that I have built with some add-ons and launched it from CLI. Nevertheless, that shouldn't affect it. Does anyone know why or what shall I do?


Solution

  • In your whole code you never defined or made a var with a name REQUIRED_PERMISSIONS.

    Try Switching from REQUIRED_PERMISSIONS to a defined var like permissions.