Search code examples
pythonpython-3.xaws-lambdaalexa-skills-kit

Not able to convert alphanumeric to string in python


I am new to python.I am working on Amazon Alexa. In that I am passing a session attribute like this

token = 2nc87nlcnclbihiuh882222a5ac4b043
session_attributes = {"Token":token}

This token contains data in alpha numeric i.e the id got from rest API. On the next function where I am passing it, it should be added in REST API header such as:

 headers = {
    'Accept': 'application/json',
    'X--Application-Id': '5gdwgjb7788e5466c27e33e40',
    'X--User-token': '2nc87nlcnclbihiuh882222a5ac4b043'
    }

When I am passing the token, variable is not working. How I can send the token as string in the header:

headers = {
    'Accept': 'application/json',
    'X--Application-Id': '5gdwgjb7788e5466c27e33e40',
    'X--User-token': token
    }

Solution

  • As mentioned in comments, token = 2nc87nlcnclbihiuh882222a5ac4b043 is not valid python.

    Try token = '2nc87nlcnclbihiuh882222a5ac4b043' instead.