Skip to content
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

V1.0 #4209

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

V1.0 #4209

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clients/sellingpartner-api-aa-csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ AWSAuthenticationCredentials awsAuthenticationCredentials = new AWSAuthenticatio
restRequest = new AWSSigV4Signer(awsAuthenticationCredentials)
.Sign(restRequest, restClient.BaseUrl.Host);
```
Note the IRestRequest reference is treated as **mutable** when signed.
Note the IRestRequest reference is treated as **mutable** when signed. **AWSSigV4 Authentication is now optional**

## RateLimitConfiguration

Expand All @@ -77,6 +77,8 @@ RateLimitConfiguration rateLimitConfig = new RateLimitConfigurationOnRequests
};

```
## Version
Selling Partner API Authentication/Authorization Library version 1.0

## Resources
This package features Mustache templates designed for use with [swagger codegen](https://swagger.io/tools/swagger-codegen/).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ namespace {{packageName}}.Client
private void InterceptRequest(IRestRequest request)
{
lwaAuthorizationSigner.Sign(request);
awsSigV4Signer.Sign(request, RestClient.BaseUrl.Host);

if(awsSigV4Signer != null && RestClient.BaseUrl.Host.Contains("business-api.amazon.com"))
{
awsSigV4Signer.Sign(request, RestClient.BaseUrl.Host);
}
}

/// <summary>
Expand All @@ -74,7 +78,10 @@ namespace {{packageName}}.Client
{{/netStandard}}

lwaAuthorizationSigner = new LWAAuthorizationSigner(Configuration.AuthorizationCredentials);
awsSigV4Signer = new AWSSigV4Signer(Configuration.AuthenticationCredentials);
if(Configuration.AuthenticationCredentials != null)
{
awsSigV4Signer = new AWSSigV4Signer(Configuration.AuthenticationCredentials);
}
rateLimitConfig = Configuration.RateLimitConfig;
if(rateLimitConfig != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,18 +464,19 @@ namespace {{packageName}}.{{apiPackage}}
throw new NullReferenceException("LWAAuthoriztionCredentials not set");
}

if (awsAuthenticationCredentials == null)
{
throw new NullReferenceException("AWSAuthenticationCredentials not set");
}

{{packageName}}.Client.Configuration configuration = new {{packageName}}.Client.Configuration()
{
AuthorizationCredentials = lwaAuthorizationCredentials,
AuthenticationCredentials = awsAuthenticationCredentials,
RateLimitConfig = rateLimitConfiguration
};


if(awsAuthenticationCredentials != null)
{
configuration.AuthenticationCredentials = awsAuthenticationCredentials;
}

// default HTTP connection timeout (in milliseconds)
configuration.Timeout = 100000;

Expand Down
8 changes: 4 additions & 4 deletions clients/sellingpartner-api-aa-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ AWSAuthenticationCredentialsProvider awsAuthenticationCredentialsProvider = AWSA
.build();

com.squareup.okhttp.Request signedRequest = new
AWSSigV4Signer(awsAuthenticationCredentialsProvider.getCredentials())
AWSSigV4Signer(awsAuthenticationCredentialsProvider)
.sign(request);

```
Note **AWSSigV4 Authentication is now optional**

## LWAAccessTokenCache
Interface to implement cache for access token that is returned in LWAClient and reuse the access token until time to live.
Expand All @@ -79,7 +79,6 @@ Interface to set and get rateLimit configurations that are used with RateLimiter

*Example*
```

com.squareup.okhttp.Request request = new Request.Builder()
.url(...)
...
Expand All @@ -89,8 +88,9 @@ com.squareup.okhttp.Request request = new Request.Builder()
.rateLimitPermit(...)
.waitTimeOutInMilliSeconds(...)
.build();

```
## Version
Selling Partner API Authentication/Authorization Library version 1.0

## Resources
This package features Mustache templates designed for use with [swagger codegen](https://swagger.io/tools/swagger-codegen/).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,11 +1049,22 @@ public class ApiClient {
}

request = lwaAuthorizationSigner.sign(request);
request = awsSigV4Signer.sign(request);

// Only sign the request using awsSigV4Signer if its setup and request is to an AmazonBusiness endpoint
if(awsSigV4Signer != null && isABEndpoint()) {
request = awsSigV4Signer.sign(request);
}
return request;
}

/**
* Find if the endpoint is for AmazonBusiness
*
* @return True, if client is setup with an AmazonBusiness endpoint else return false
*/
public boolean isABEndpoint() {
return basePath.contains("business-api.amazon.com");
}

/**
* Build full URL by concatenating base path, the given sub path and query parameters.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ public class {{classname}} {


public {{classname}} build() {
if (awsAuthenticationCredentials == null && awsAuthenticationCustomCredentialsProvider == null) {
throw new RuntimeException("Neither AWSAuthenticationCredentials or AWSAuthenticationCustomCredentialsProvider are set");
}

if (lwaAuthorizationCredentials == null) {
throw new RuntimeException("LWAAuthorizationCredentials not set");
}
Expand All @@ -345,15 +341,16 @@ public class {{classname}} {
throw new RuntimeException("Endpoint not set");
}

AWSSigV4Signer awsSigV4Signer;
AWSSigV4Signer awsSigV4Signer = null;
if (awsAuthenticationCustomCredentialsProvider != null ) {
awsSigV4Signer = new AWSSigV4Signer(awsAuthenticationCustomCredentialsProvider);
}
else if (awsAuthenticationCredentialsProvider == null) {
awsSigV4Signer = new AWSSigV4Signer(awsAuthenticationCredentials);
}
else {
awsSigV4Signer = new AWSSigV4Signer(awsAuthenticationCredentials,awsAuthenticationCredentialsProvider);
else if (awsAuthenticationCredentials != null) {
if (awsAuthenticationCredentialsProvider == null) {
awsSigV4Signer = new AWSSigV4Signer(awsAuthenticationCredentials);
} else {
awsSigV4Signer = new AWSSigV4Signer(awsAuthenticationCredentials, awsAuthenticationCredentialsProvider);
}
}

LWAAuthorizationSigner lwaAuthorizationSigner = null;
Expand All @@ -367,11 +364,16 @@ public class {{classname}} {
lwaAuthorizationSigner = new LWAAuthorizationSigner(lwaAuthorizationCredentials,lwaAccessTokenCache);
}

return new {{classname}}(new ApiClient()
.setAWSSigV4Signer(awsSigV4Signer)
ApiClient apiClient = new ApiClient()
.setLWAAuthorizationSigner(lwaAuthorizationSigner)
.setBasePath(endpoint)
.setRateLimiter(rateLimitConfiguration));
.setRateLimiter(rateLimitConfiguration);

if (awsSigV4Signer != null) {
apiClient.setAWSSigV4Signer(awsSigV4Signer);
}

return new {{classname}}(apiClient);
}
}
}
Expand Down