Sha256: fc4ef1406a440f007d8947e286f6c3545a52ad1e1e8eb9e3a84b188a199d0415

Contents?: true

Size: 754 Bytes

Versions: 3

Compression:

Stored size: 754 Bytes

Contents

require_relative '../uri_provider'

module MangoApi

  # Provides API method delegates for OAuth authentication.
  module OAuthTokens
    class << self
      include UriProvider

      # Creates a new configuration-specific authorization token.
      #
      # @param +mangopay_config+ The MangoPay environment configuration
      def create(mangopay_config)
        uri = provide_uri(:create_token)
        HttpClient.post_raw(uri) do |request|
          config = mangopay_config
          request.basic_auth config.client_id, config.client_apiKey
          request.body = 'grant_type=client_credentials'
          request.add_field('Content-Type',
                            'application/x-www-form-urlencoded')
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mangopay-v4-4.1.0 lib/mangopay/api/service/oauth_tokens.rb
mangopay-v4-4.0.2 lib/mangopay/api/service/oauth_tokens.rb
mangopay-v4-4.0.1 lib/mangopay/api/service/oauth_tokens.rb