question

Albebach avatar image
Albebach asked

ServiceException in get_in_skill_products - Error 403

*NEW INSIGHT!*: This skill works as intended every once in a while, leading me to believe that there is an issue with Amazon's CloudFront service, and not with my skill. I have had success running the skill 2 out of 10 times so far (changing no code).

-------------------------------------------------------------

403errorforalexa.txt

Hello! I'm using a StandardSkillBuilder() in python and calling the following lines from within an intent:

locale = handler_input.request_envelope.request.locale
ms = handler_input.service_client_factory.get_monetization_service()
in_skill_response = ms.get_in_skill_products(locale)

I have a product registered for my locale (GUID and filename changed for anonymity):

DEPLOY STATUS | ID                                                     | FILE
Update        | amzn1.adg.product.aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee | isps\entitlement\MyProduct.json

And yet, I get an error when the BaseServiceClient is invoked:

<H2>The request could not be satisfied.</H2> 

Can anyone provide any insight? I have attached the stack trace and the output from CloudFront which I scraped from line 94 of base_service_client.py; I've also included the handler_input.request_envelope.to_dict() in case that is helpful. Thank you!

monetization
3 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

(regarding the attached information: on second thought, request_envelope.to_dict() contained some sensitive information such as api keys, and I felt it better to leave that out)

0 Likes 0 ·

Tested again this morning, and -- again -- intermittent success. Success seems to come in waves -- the skill will work perfectly for a 10 minute stretch and then quit working for an extended period of time.

0 Likes 0 ·

My skill ID, should it become useful, is:

amzn1.ask.skill.d1311184-0f57-46e8-ab59-879027130a28
0 Likes 0 ·
Albebach avatar image
Albebach answered

Hi everyone. You should know that this is *RESOLVED* in so far as there is a workaround.

The bug is in the Python3.6 SDK, in the authentication token verification portion, and the Python2.7 SDK works perfectly. If you're experiencing this issue of not being able to use ISPs with 3.6, just switch your code to 2.7, download the 2.7 SDK, and switch your lambda to run in a Python 2.7 environment.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Albebach avatar image
Albebach answered

Interestingly, this seems to be related, as I receive the same 403 error:
https://forums.developer.amazon.com/questions/176660/api-isp-call-with-connectionssendrequest-token-wor.html

Perhaps the best way to handle this (which I'll try next) is to fetch the ISP information once and only once upon initialization of the skill, cache that data in a local object, and just reference the object until the purchase flow begins...

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Albebach avatar image
Albebach answered

I've refactored my code to ping the service once and only once upon launch of the skill, storing that information in an object for retrieval from within the desired intent. _However_, I am still hitting the same issue.

This is a blocking issue -- I cannot use the monetization service when it does not function for my customers! @KAIYIN@AMAZON.COM, I've seen you answer a few monetization questions in the past -- any chance we can get some Amazon eyeballs on this issue? Please and thanks.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Albebach avatar image
Albebach answered

Update: I am still running into the 403 error trying to access the monetization service.

@KAIYIN@AMAZON.COM, did you see my tag from last week? ... @Anand@Amazon maybe?

status_code=403, headers=[('Server', 'CloudFront'), ('Date', 'Mon'), ('Date', '01 Oct 2018 17:57:58 GMT'), ('Content-Type', 'text/html'), ('Content-Length', '556'), ('Connection', 'keep-alive'), ('X-Cache', 'Error from cloudfront'), ('Via', '1.1 a00eb4657c3b62cedb9b6571825eb82d.cloudfront.net (CloudFront)'), ('X-Amz-Cf-Id', 'vKRInFT0M7v8PCIMOsunLG0aRvIgHZkNGCKz0cIHVgSVTalpv1EQew==')], body=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Albebach avatar image
Albebach answered

Here's an interesting detail in the docs at https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html:

"AWS Lambda includes the AWS SDK for Python (Boto 3), so you don't need to include it in your deployment package."
I wonder if my issue stems from having included that source code in my lambda package...

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Albebach avatar image
Albebach answered

Anyone from Amazon? Help?

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jason@Amazon avatar image
Jason@Amazon answered

Reach out to us here where we will be able to assist further, as it looks like you might have some sensitive information specific to your account and we can work on it there.

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

THANK YOU, JASON!!! Thank you thank you thank you. Just sent the form now. <sigh of relief>

0 Likes 0 ·
Albebach avatar image
Albebach answered

In case anyone is following, this continues to be a problem after nearly a month, despite mine and Amazon's best efforts to debug it. In fact, all one needs to do to replicate this is to create a skill in Python 3.6 that calls the monetization service, and a CloudFront 403 error will result. The simplest way to replicate the error is to:
* clone this repo: https://github.com/alexa/skill-sample-python-fact-in-skill-purchases
* install the ask_sdk to the lambda directory
* use ask CLI to add isps (then move the sample isps into place in the newly created isps/ directory)
* ask deploy
when the skill is called, you'll hear "Sorry, I'm not able to understand the command" or something similar, and you can check the CloudWatch logs to see the "Unknown Error".

Take it from us, if you break open the ask_sdk and pepper print statements in there, this UnknownError is raised when CloudWatch returns a 403 error. (and yes, before you ask, we have full CloudWatch permissions on our lambda).

This is without question a problem in the ask_sdk for python 3, but nobody at Amazon seems to be willing or able to nail down exactly what the issue is. I'll continue to keep you posted.

4 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I am getting the same error when trying to access the household lists. Any updates on this would be very helpful!

0 Likes 0 ·
@goova

I've just created this walkthrough for Amazon. Hopefully this helps: https://www.youtube.com/watch?v=l2n60pN5XfE

0 Likes 0 ·

Hey Albebach,

I am working on this issue with the ISP team and will give you update soon. Please give us some time to find out the root cause what preventing to call monetization service API?

0 Likes 0 ·
Show more comments