alexa / alexa-skills-kit-sdk-for-nodejs

The Alexa Skills Kit SDK for Node.js helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
Apache License 2.0
3.12k stars 736 forks source link

ListManagementService isn't accepting the apiAccessToken anymore #683

Closed TimeO84 closed 3 years ago

TimeO84 commented 3 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

ListManagementService isn't acception the apiAccessToken anymore, you have to use the deprecated consentToken

Expected Behavior

let ListManagementService = handlerInput.serviceClientFactory.getListManagementServiceClient(); let listresp =await ListManagementService.getListsMetadata();

Current Behavior

let ListManagementService = handlerInput.serviceClientFactory.getListManagementServiceClient();
let listresp =await ListManagementService.getListsMetadata(); 

Above Code throws this exception:

2021-02-23T10:00:50.240Z db1b9afc-2542-433d-8b92-a92135c8f04e INFO getListsMetadata Ex Error [ServiceError]: Forbidden at ListManagementServiceClient. (/var/task/node_modules/ask-sdk-model/index.js:219:35) at step (/var/task/node_modules/ask-sdk-model/index.js:45:23) at Object.next (/var/task/node_modules/ask-sdk-model/index.js:26:53) at fulfilled (/var/task/node_modules/ask-sdk-model/index.js:17:58) at processTicksAndRejections (internal/process/task_queues.js:97:5) { statusCode: 403, response: { Message: 'Request is not authorized.' } }

Possible Solution

let ListManagementService = handlerInput.serviceClientFactory.getListManagementServiceClient();
ListManagementService.apiConfiguration.authorizationValue = handlerInput.requestEnvelope.session.user.permissions.consentToken;
let listresp =await ListManagementService.getListsMetadata();

Steps to Reproduce (for bugs)

let ListManagementService = handlerInput.serviceClientFactory.getListManagementServiceClient();
let listresp =await ListManagementService.getListsMetadata();

Context

My Skill stopped working until i found the described Workaround

Your Environment

Node.js and NPM Info

ShenChen93 commented 3 years ago

Hi @TimeO84 ,

Thanks for using our SDK ! For this issue, I wonder if you correctly grant permission to the skills, here is the doc for instruction: https://developer.amazon.com/en-US/docs/alexa/custom-skills/access-the-alexa-shopping-and-to-do-lists.html#integrate-list-management-capabilities-into-your-skill.

Basically, you would need to first go to developer console, at the permission tab, you need to config that the skill may need read / write list: image

Second, go to your Alexa App, find the skills & games list and find the skill you are developing. If you finished the fist step, you will see the setting button, go to setting and grant permission to the skill.

I am able to get the list after I finished above two steps. Let me know if it works for you :)

Thanks, Shen

TimeO84 commented 3 years ago

Hello Shen,

all my permissions are set correctly. It stopped working for about 2 weeks. If i use the given consentToken I am able to retrieve the Lists Metadata. Maybe i am wrong on GitHub with this Problem and it is a Problem with the Service itself.

ShenChen93 commented 3 years ago

Hi @TimeO84 ,

Umm, if so probably we can't help you investigate the root cause. I would recommend you to log this issue to Alexa Forum, thus people from service team could works with you to figure it out.

Closing this ticket from sdk side for now. Please feel free to reopen if you have any other concerns :)

Thanks, Shen

ShenChen93 commented 3 years ago

@TimeO84

Actually Alexa just set up a 3P slack community: http://alexa.design/slack. Maybe you could also log question there ?