Method: DocuSign_Monitor::ApiClient#generate_access_token
- Defined in:
- lib/docusign_monitor/client/api_client.rb
#generate_access_token(client_id, client_secret, code) ⇒ Object
GenerateAccessToken will exchange the authorization code for an access token and refresh tokens.
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/docusign_monitor/client/api_client.rb', line 557 def generate_access_token(client_id, client_secret, code) raise ArgumentError.new('client_id cannot be empty') if client_id.empty? raise ArgumentError.new('client_secret cannot be empty') if client_secret.empty? raise ArgumentError.new('code cannot be empty') if code.empty? authcode = "Basic " + Base64.strict_encode64("#{client_id}:#{client_secret}") params = { :header_params => { "Authorization" => authcode, "Content-Type" => "application/x-www-form-urlencoded" }, :form_params => { "grant_type" => 'authorization_code', "code" => code, }, :return_type => 'OAuth::OAuthToken', :oauth => true } data, status_code, headers = self.call_api("POST", '/oauth/token', params) abort(data.inspect) end |