Class: Docusigner::Oauth2

Inherits:
Base
  • Object
show all
Defined in:
lib/docusigner/oauth2.rb

Class Method Summary collapse

Methods inherited from Base

act_as_user, authorization=, connection, headers, #to_json, token=

Methods included from Multipart::Resource

#add_document, #encode

Class Method Details

.revoke(token) ⇒ Object



16
17
18
19
20
21
# File 'lib/docusigner/oauth2.rb', line 16

def revoke(token)
  @headers = {
    "Authorization" => "Bearer #{token}"
  }
  post(:revoke, {}, "")
end

.token(username, password, integrator_key) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/docusigner/oauth2.rb', line 6

def token(username, password, integrator_key)
  @headers = {
    "Accept" => "application/json",
    "Content-Type" => "application/x-www-form-urlencoded"
  }
  body = "grant_type=password&client_id=#{integrator_key}&username=#{username}&password=#{password}&scope=api"
  resp = post(:token, {}, body) 
  format.decode(resp.body)["access_token"]
end