Hello to everyone!!!
I need some help with my Alexa Skill that some weeks ago worked but now when i try to access the list i have this error:
{'Message': 'Request is not authorized.'} <Response [403]>
1. I have enabled the List Read and List Write in the Alexa Companion App.
2. This is part of my AWS Lambda code related to the creation of the list:
def get_headers(event): if 'apiAccessToken' in event['context']['System']: apiAccessToken = event['context']['System']['apiAccessToken'] headers = { 'Authorization': 'Bearer '+apiAccessToken, 'Content-Type': 'application/json' } return headers else: logger.info('apiAccessToken not found') return False def create_list(event, list_title, list_items=[]): logger.info(event) headers = get_headers(event) logger.info(headers) if not headers: return False data = { "name": list_title, "state": "active" } # url = event['context']['System']['apiEndpoint'] + '/v2/householdlists/' url = "https://api.amazonalexa.com/v2/householdlists/" logger.info(url) r = requests.post(url, headers=headers, data=json.dumps(data)) logger.info(r) logger.info(r.json()) if r.status_code == 201: logger.info('List created') listId = r.json()['listId'] for list_item in reversed(list_items): post_list_item(event, listId, headers, list_item) return True elif r.status_code == 409: logger.info('List already exists') return True elif r.status_code == 403: logger.info('List permissions not granted') return False else: logger.info(r.status_code) logger.info(r.json()) return True
This is the event response:
{ "version":"1.0", "session":{ "new":true, "sessionId":"amzn1.echo-api.session.a86b68d7-c996-4b06-9613-5fcf0260e26a", "application":{ "applicationId":"amzn1.ask.skill.70dad2a2-51d5-454b-a1bb-734342b96c05" }, "user":{ "userId":"I have hidden THIS", "permissions":{ "consentToken":"I have hidden THIS" } } }, "context":{ "AudioPlayer":{ "playerActivity":"FINISHED" }, "Extensions":{ "available":{ } }, "System":{ "application":{ "applicationId":"amzn1.ask.skill.70dad2a2-51d5-454b-a1bb-734342b96c05" }, "user":{ "userId":"I have hidden THIS", "permissions":{ "consentToken":"I have hidden THIS" } }, "device":{ "deviceId":"I have hidden THIS", "supportedInterfaces":{ "AudioPlayer":{ } } }, "apiEndpoint":"https://api.eu.amazonalexa.com", "apiAccessToken":"Token", "unit":{ "unitId":"I have hidden THIS" } } }, "request":{ "type":"LaunchRequest", "requestId":"amzn1.echo-api.request.2200b726-f046-47b2-a9e6-01566e2c77b2", "timestamp":"2021-02-22T10:45:32Z", "locale":"it-IT", "shouldLinkResultBeReturned":false } }
This is the Header in the post:
{ "Authorization":"Bearer I have Hidden THIS", "Content-Type":"application/json" }
This is the URL:
https://api.eu.amazonalexa.com/v2/householdlists/
I hope someone could help me
Best Regards
Stefano