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

dropped AWS signature #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 5 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

AmzSpApi - Unofficial Ruby gem for the Amazon Selling Partner API (SP-API)

This SDK is automatically generated by running [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) on each model from https://github.com/amzn/selling-partner-api-models using the [codegen.sh](codegen.sh) script.
This SDK is automatically generated by running [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) on each model from https://github.com/amzn/selling-partner-api-models using the [codegen.sh](codegen.sh) script.

Auto-generated documentation is nested here: This is a handy way to see all the API model class names and corresponding files you need to require for them, e.g. require 'finances-api-model' to use https://www.rubydoc.info/gems/amz_sp_api/AmzSpApi/FinancesApiModel/DefaultApi

but https://developer-docs.amazon.com/sp-api is more comprehensive.
but https://developer-docs.amazon.com/sp-api is more comprehensive.

## Installation

Expand All @@ -22,22 +22,9 @@ require 'amz_sp_api'
require 'fulfillment-outbound-api-model'

AmzSpApi.configure do |config|
config.refresh_token =
config.client_id =
config.client_secret =

# either use these:
config.aws_access_key_id =
config.aws_secret_access_key =

# OR config.credentials_provider which is passed along to https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html, e.g.
# require 'aws-sdk-core'
# config.credentials_provider = Aws::STS::Client.new(
# region: AmzSpApi::SpConfiguration::AWS_REGION_MAP['eu'],
# access_key_id: ,
# secret_access_key:
# ).assume_role(role_arn: , role_session_name: SecureRandom.uuid)

config.refresh_token =
config.client_id =
config.client_secret =
config.region = 'eu'
config.timeout = 20 # seconds
# config.debugging = true
Expand Down
1 change: 0 additions & 1 deletion amz_sp_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Gem::Specification.new do |s|

s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
s.add_runtime_dependency 'json'
s.add_runtime_dependency 'aws-sigv4', '~> 1.2'

s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'

Expand Down
5 changes: 1 addition & 4 deletions lib/restricted_sp_api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ def request_rdt_access_token
end

def auth_headers(http_method, url, body)
SpApiClient.signed_request_headers(config, http_method, url, body).merge({
'x-amz-access-token' => retrieve_rdt_access_token
})
{ 'x-amz-access-token' => retrieve_rdt_access_token }
end

end
end
21 changes: 1 addition & 20 deletions lib/sp_api_client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'aws-sigv4'

require 'api_error'
require 'api_client'

Expand All @@ -18,21 +16,6 @@ def call_api(http_method, path, opts = {})
super(http_method, path, signed_opts)
end

def self.signed_request_headers(config, http_method, url, body)
request_config = {
service: 'execute-api',
region: config.aws_region
}
if config.credentials_provider
request_config[:credentials_provider] = config.credentials_provider
else
request_config[:access_key_id] = config.aws_access_key_id
request_config[:secret_access_key] = config.aws_secret_access_key
end
signer = Aws::Sigv4::Signer.new(request_config)
signer.sign_request(http_method: http_method.to_s, url: url, body: body).headers
end

private

def retrieve_lwa_access_token
Expand Down Expand Up @@ -74,9 +57,7 @@ def request_lwa_access_token
end

def auth_headers(http_method, url, body)
self.class.signed_request_headers(config, http_method, url, body).merge({
'x-amz-access-token' => retrieve_lwa_access_token
})
{ 'x-amz-access-token' => retrieve_lwa_access_token }
end
end
end
1 change: 0 additions & 1 deletion lib/sp_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module AmzSpApi
class SpConfiguration < Configuration
attr_accessor :refresh_token, :client_id, :client_secret, :sandbox, :region,
:aws_access_key_id, :aws_secret_access_key, :credentials_provider, # either access key or credentials_provider for AWS Signer, e.g. Aws::STS::Client
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these incompatible API changes would force this to be part of a major version change whereas if we left them in place and even better added this we could roll it out in a patch

  extend Gem::Deprecate
  deprecate :aws_access_key_id=, :none, 2025, 1
  deprecate :aws_secret_access_key=, :none, 2025, 1
  deprecate :credentials_provider=, :none, 2025, 1

:save_access_token, :get_access_token # optional lambdas for storing and retrieving token

# from https://github.com/amzn/selling-partner-api-docs/blob/main/guides/developer-guide/SellingPartnerApiDeveloperGuide.md#selling-partner-api-endpoints
Expand Down