Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

amazon mws - Problem with LWA Token Exchange using Selling-Partner Java SDK

My code

AWSAuthenticationCredentials awsAuthenticationCredentials = AWSAuthenticationCredentials.builder()
                .accessKeyId("XXXXXXXXXXXXXXX").secretKey("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                .region("eu-west-1").build();
        
        AWSAuthenticationCredentialsProvider awsAuthenticationCredentialsProvider = AWSAuthenticationCredentialsProvider
                .builder().roleArn("XXXXXXXXXXXXX").roleSessionName("123123123")
                .build();



        LWAAuthorizationCredentials lwaAuthorizationCredentials = LWAAuthorizationCredentials.builder()
                .clientId("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                .clientSecret("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                .endpoint("https://api.amazon.com/auth/o2/token").build();


        SellersApi sellersApi = new SellersApi.Builder().awsAuthenticationCredentials(awsAuthenticationCredentials)
                .lwaAuthorizationCredentials(lwaAuthorizationCredentials)
                .awsAuthenticationCredentialsProvider(awsAuthenticationCredentialsProvider)
                .endpoint("https://sellingpartnerapi-eu.amazon.com").build();

        GetMarketplaceParticipationsResponse res = sellersApi.getMarketplaceParticipations();
        List<MarketplaceParticipation> data = new ArrayList<MarketplaceParticipation>();
        data = res.getPayload();
        for (MarketplaceParticipation obj : data) {
            System.out.println(obj);
        }

Error:

Caused by: java.lang.RuntimeException: Error getting LWA Access Token at com.amazon.SellingPartnerAPIAA.LWAClient.getAccessTokenFromEndpoint(LWAClient.java:74) at com.amazon.SellingPartnerAPIAA.LWAClient.getAccessTokenFromCache(LWAClient.java:51) at com.amazon.SellingPartnerAPIAA.LWAClient.getAccessToken(LWAClient.java:40) at com.amazon.SellingPartnerAPIAA.LWAAuthorizationSigner.sign(LWAAuthorizationSigner.java:69) at com.amazon.sellingpartner.ApiClient.buildRequest(ApiClient.java:1034) at com.amazon.sellingpartner.ApiClient.buildCall(ApiClient.java:973) at com.amazon.sellingpartner.api.SellersApi.getMarketplaceParticipationsCall(SellersApi.java:111) at com.amazon.sellingpartner.api.SellersApi.getMarketplaceParticipationsValidateBeforeCall(SellersApi.java:118) at com.amazon.sellingpartner.api.SellersApi.getMarketplaceParticipationsWithHttpInfo(SellersApi.java:141) at com.amazon.sellingpartner.api.SellersApi.getMarketplaceParticipations(SellersApi.java:130) at com.yash.spapi.TestSpApiApplication.main(TestSpApiApplication.java:47) ... 5 more Caused by: java.io.IOException: Unsuccessful LWA token exchange at com.amazon.SellingPartnerAPIAA.LWAClient.getAccessTokenFromEndpoint(LWAClient.java:63) ... 15 more

question from:https://stackoverflow.com/questions/65886322/problem-with-lwa-token-exchange-using-selling-partner-java-sdk

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...