class Peddler::Token
Requests refresh and access tokens that authorize your application to take actions on behalf of a selling partner.
The refresh token allows you to generate access tokens. Access tokens expire one hour after they are issued.
@see developer-docs.amazon.com/sp-api/docs/connecting-to-the-selling-partner-api
Constants
- Error
- URL
Attributes
Public Class Methods
Source
# File lib/peddler/token.rb, line 26 def initialize(client_id: ENV["LWA_CLIENT_ID"], client_secret: ENV["LWA_CLIENT_SECRET"], **options) @client_id = client_id @client_secret = client_secret @options = options end
Public Instance Methods
Source
# File lib/peddler/token.rb, line 37 def grant_type if options.key?(:grant_type) options[:grant_type] elsif options.key?(:refresh_token) "refresh_token" elsif options.key?(:scope) "client_credentials" elsif options.key?(:code) "authorization_code" end end
Source
# File lib/peddler/token.rb, line 32 def request response = HTTP.post(URL, form: params) Response.wrap(response) end
Private Instance Methods
Source
# File lib/peddler/token.rb, line 51 def params { grant_type: grant_type, client_id: client_id, client_secret: client_secret, }.compact.merge(options) end