Module: Inkdit
- Defined in:
- lib/inkdit.rb,
lib/inkdit/client.rb,
lib/inkdit/entity.rb,
lib/inkdit/version.rb,
lib/inkdit/contract.rb,
lib/inkdit/resource.rb,
lib/inkdit/signature.rb,
lib/inkdit/form_contract.rb,
lib/inkdit/signature_field.rb
Defined Under Namespace
Classes: Client, Contract, Entity, Error, FormContract, Resource, Signature, SignatureField, Unauthorized
Constant Summary collapse
- Config =
global configuration for the client. this has to be set up for anything to work. It must have the keys:
api_key
-
your application’s API key, obtained from developer.inkdit.com/
secret
-
your application’s shared secret, obtained from developer.inkdit.com/
It can optionally have the key:
debug
-
true
if you want HTTP requests and responses printed to stdout.
{}
- VERSION =
"1.1.0"
Class Method Summary collapse
-
.authorization_code_url(scopes, redirect_uri) ⇒ String
The URL that the user should be sent to to obtain an authorization code.
-
.get_token(authorization_code, redirect_uri) ⇒ OAuth2::AccessToken
requests an access token using an authorization code (OAuth 2 section 4.1.3/4.1.4).
-
.oauth_client ⇒ OAuth2::Client
you probably don’t want to call this.
Class Method Details
.authorization_code_url(scopes, redirect_uri) ⇒ String
Returns the URL that the user should be sent to to obtain an authorization code. (OAuth 2 section 4.1.1).
32 33 34 35 |
# File 'lib/inkdit.rb', line 32 def self.(scopes, redirect_uri) scopes = scopes.join('%20') "https://inkdit.com/oauth?response_type=code&client_id=#{Config['api_key']}&scope=#{scopes}&redirect_uri=#{redirect_uri}" end |
.get_token(authorization_code, redirect_uri) ⇒ OAuth2::AccessToken
requests an access token using an authorization code (OAuth 2 section 4.1.3/4.1.4)
58 59 60 |
# File 'lib/inkdit.rb', line 58 def self.get_token(, redirect_uri) self.oauth_client.auth_code.get_token(, :redirect_uri => redirect_uri) end |
.oauth_client ⇒ OAuth2::Client
you probably don’t want to call this.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/inkdit.rb', line 40 def self.oauth_client # :nodoc: api_key = Inkdit::Config['api_key'] secret = Inkdit::Config['secret'] opts = { :site => 'https://api.inkdit.com/', :token_url => '/token', :raise_errors => false } OAuth2::Client.new(api_key, secret, opts) end |