-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doing a resolveCustomer() call using temporary credentials. #10
Comments
const marketplacemetering = new MarketplaceMeteringClient({
region: 'us-west-2',
credentials: new Credentials(tempCredentials)
});
|
Where do I get the Credentials object in JavaScript SDK Version 3?
Your linked example would require (I think) |
Ok, I am wrong. First, credentials now are brought in via providers that implement a basic Credentials interface, so you can just use a plain object/hash as you did, or a specific provider, such as
So that's not the problem here. I upgraded a sample in aws-samples/aws-dataexchange-api-samples#45 to AWS SDK v3 and I didn't need to do that anymore. I'll gladly take a look at your code if you can put it up on GitHub, and tell me how to reproduce the issue? |
This code fragment should be all that you need. Just start with a sessiontoken, Accesskey, and secretkey that have the ability to make the resolveCustomer() call. If this works properly, you should get a 400 response code and an "InvalidToken" error.
|
I put this code up in aws-samples/aws-marketplace-api-samples#4 and I get the expected error.
|
Yup. Works for me too. But when I use the exact same code in a React component, I get the dreaded
It claims to be a CORS error (I'm running from Localhost in a web browser):
But if it is a CORS error, why can I successfully make STSClient and CognitoIdentityClient API calls in the web browser just before that without any CORS errors? |
Aha, so this is the actual problem. This is because metering does not support/allow CORS, see https://github.com/aws/aws-sdk-js/blob/master/SERVICES.md that says which ones do and which ones don't. I am not sure what the rationale is for allowing/disallowing CORS. What are you trying to build? |
My SaaS needs to make a resolveCustomer() call to determine if the incoming x-amzn-marketplace-token token is valid. Since this is a serverless SaaS (eventually, JS running from an S3 bucket), the call is from JS. |
I have flagged this to someone in AWS who's close to this service, but I think it's a feature request at this point, so you should probably open a ticket with support, and ask for it, pointing this conversation. |
I see that the resolveCuatomer() call is in a Lambda function in this project. Do the AWS access credentials have to be tied to a specific account in order to get the right results for resolvecustomer() or can anyone with permission to make the call do it? |
@gjoshevski care to comment on ^? |
From https://docs.aws.amazon.com/marketplacemetering/latest/APIReference/API_ResolveCustomer.html
|
The next (obvious?) question is: It's very common to have development and production in separate AWS accounts. What's the best practice for testing Marketplace integration in that scenario? Can you signup using your development account and then later switch to production? |
Our recommendation is to use your prod account to test with test products. We don't have a way to switch accounts. However, be aware throttling limits are per account and any test usage will impact your product usage. |
This might be useful for sites that want to have unauthenticated users doing the resolveCustomer() call.
I am successfully generating an AccessKey, SecretKey, and SessionToken associated with a Role that permits the temporary user to make resolveCustomer() calls.
I can prove that these credentials can successfully do a resolveCustomer() call by setting env vars:
(without setting these, it can't find credentials).
And then doing the relevant CLI call:
aws meteringmarketplace resolve-customer --registration-token asdfa --region us-west-2
This should return an "InvalidToken" error.
Works great. However, I want to do this using the JavaScript SDK v3.
My attempt looks like this:
The call returns "TypeError: Failed to fetch" which usually means that the Api call is just not setup properly.
What I'm expecting is a 400 error of type InvalidToken.
Any thoughts?
The text was updated successfully, but these errors were encountered: