-
Notifications
You must be signed in to change notification settings - Fork 6
Changes for refresh amazon app client secret #88
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
Changes from 1 commit
0f37271
9adff6c
9719d32
4335859
cfeb61a
0a26be2
5b12f0a
35e1949
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| module MuffinMan::ApiAccountCredential | ||
|
||
| class CredentialHelper | ||
| NEW_APP_CREDENTIAL_URL = "https://sellingpartnerapi-na.amazon.com/applications/2023-11-30/clientSecret".freeze | ||
|
|
||
| def self.create_new_credentials(access_token) | ||
| response = Typhoeus.post( | ||
| NEW_APP_CREDENTIAL_URL, | ||
| headers: { | ||
| "x-amz-access-token" => "#{access_token}" | ||
| } | ||
| ) | ||
| if response.code != 204 | ||
| error_body = JSON.parse(response.body) | ||
| error = "#{error_body['error']}: #{error_body['error_description']} " | ||
| raise MuffinMan::Error, error | ||
| end | ||
| response.code | ||
| end | ||
| end | ||
| end | ||
nitinbhakar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,5 +23,27 @@ def self.get_refresh_token(client_id, client_secret, auth_code) | |
| end | ||
| JSON.parse(response.body)["refresh_token"] | ||
| end | ||
|
|
||
| def self.get_client_credential_refresh_token(client_id, client_secret) | ||
|
||
| body = { | ||
| grant_type: "client_credentials", | ||
nitinbhakar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| client_id: client_id, | ||
| client_secret: client_secret | ||
| } | ||
|
|
||
| response = Typhoeus.post( | ||
| ACCESS_TOKEN_URL, | ||
| body: URI.encode_www_form(body), | ||
| headers: { | ||
| "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8" | ||
| } | ||
| ) | ||
| if response.code != 200 | ||
| error_body = JSON.parse(response.body) | ||
| error = "#{error_body["error"]}: #{error_body["error_description"]}" | ||
| raise MuffinMan::Error, error | ||
| end | ||
| JSON.parse(response.body)["refresh_token"] | ||
| end | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should just be like how the other APIs have been implemented where a sp api client can be created for Application Management API v2023-11-30.