Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ access_token = MuffinMan::Lwa::AuthHelper.get_access_token(scope, client_id, cli
### Rotating application client secret
To rotate client secret for application
```ruby
MuffinMan::ApplicationManagement::V20231130.rotate_application_client_secret(access_token)
MuffinMan::ApplicationManagement::V20231130.rotate_application_client_secret(client_id,client_secret)
```

### Debugging
Expand Down
4 changes: 3 additions & 1 deletion lib/muffin_man/application_management/v20231130.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
module MuffinMan
module ApplicationManagement
class V20231130
def self.rotate_application_client_secret(access_token)
def self.rotate_application_client_secret(client_id, client_secret)
access_token = MuffinMan::Lwa::AuthHelper.get_access_token("sellingpartnerapi::client_credential:rotation",
client_id, client_secret)
Typhoeus.post(
"https://sellingpartnerapi-na.amazon.com/applications/2023-11-30/clientSecret",
headers: { "x-amz-access-token" => access_token }
Expand Down
8 changes: 7 additions & 1 deletion spec/muffin_man/application_management/v20231130_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

RSpec.describe MuffinMan::ApplicationManagement::V20231130 do
let(:access_token) { "test_access_token" }
let(:client_id) { "test_client_id" }
let(:client_secret) { "test_client_secret" }
let(:new_app_credential_url) { "https://sellingpartnerapi-na.amazon.com/applications/2023-11-30/clientSecret" }

describe ".rotate_application_client_secret" do
let(:response) { instance_double(Typhoeus::Response) }

before do
allow(MuffinMan::Lwa::AuthHelper).to receive(:get_access_token)
.with("sellingpartnerapi::client_credential:rotation", client_id, client_secret)
.and_return(access_token)

allow(Typhoeus).to receive(:post).and_return(response)
end

Expand All @@ -23,7 +29,7 @@
headers: { "x-amz-access-token" => access_token }
)

result = described_class.rotate_application_client_secret(access_token)
result = described_class.rotate_application_client_secret(client_id, client_secret)
expect(result).to eq(response)
end
end
Expand Down
Loading