Sha256: b36ee7c351f88e0c9f1386785c9bb1098f400df569a1ad53b1d5bf6c6440f31f
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require 'ebay/config' require 'ebay/requestable' module Ebay module Oauth # Mints an access token to use in API requests # # @see https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html class ClientCredentialsGrant include Requestable self.endpoint = 'https://api.ebay.com/identity/v1/oauth2/token' # @return [String] attr_reader :app_id # @return [String] attr_reader :cert_id # @param [String] app_id # @param [String] cert_id def initialize(app_id: Config.app_id, cert_id: Config.cert_id) @app_id = app_id @cert_id = cert_id end # Mints a new access token # # @return [String] def mint_access_token JSON.parse(request).fetch('access_token') end # Requests a client credentials grant # # @return [HTTP::Response] def request HTTP.basic_auth(user: app_id, pass: cert_id) .post(endpoint, form: payload) end private def payload { grant_type: 'client_credentials', scope: 'https://api.ebay.com/oauth/api_scope' } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ebay-ruby-0.3.2 | lib/ebay/oauth/client_credentials_grant.rb |
ebay-ruby-0.3.1 | lib/ebay/oauth/client_credentials_grant.rb |