Module: MangoApi::OAuthTokens

Extended by:
UriProvider
Defined in:
lib/mangopay/api/service/oauth_tokens.rb

Overview

Provides API method delegates for OAuth authentication.

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.create(mangopay_config) ⇒ Object

Creates a new configuration-specific authorization token.

Parameters:

  • +mangopay_config+

    The MangoPay environment configuration



13
14
15
16
17
18
19
20
21
22
# File 'lib/mangopay/api/service/oauth_tokens.rb', line 13

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