Module: HelloSign::Api::OAuth
- Included in:
- Client
- Defined in:
- lib/hello_sign/api/oauth.rb
Overview
OAuth allows you to perform actions on behalf of other users after they grant you the authorization to do so. For example, you could send signature requests on behalf of your users. For more information, see our OAuth API documentation (app.hellosign.com/api/oauthWalkthrough).
IMPORTANT: With some OAuth scopes, you (the app owner) will be charged for all signature requests sent on behalf of other users via your app.
Instance Method Summary collapse
-
#get_oauth_token(opts) ⇒ Hash
Retrieves the OAuth token.
-
#oauth_create_account(opts) ⇒ Hash
Create new user and get their OAuth token.
-
#oauth_url(state) ⇒ type
Returns the OAuth URL where users can give permission for your application to perform actions on their behalf.
-
#refresh_oauth_token(opts) ⇒ Hash
Refreshes the user’s OAuth token.
Instance Method Details
#get_oauth_token(opts) ⇒ Hash
Retrieves the OAuth token
62 63 64 65 66 67 |
# File 'lib/hello_sign/api/oauth.rb', line 62 def get_oauth_token(opts) opts[:client_id] = self.client_id opts[:client_secret] = self.client_secret opts[:grant_type] = 'authorization_code' post('/oauth/token', { :body => opts, :oauth_request => true }) end |
#oauth_create_account(opts) ⇒ Hash
Create new user and get their OAuth token. The user will receive an email asking them to confirm the access being granted. Your app will not be able to perform actions on behalf of this user until they confirm.
95 96 97 98 99 100 |
# File 'lib/hello_sign/api/oauth.rb', line 95 def oauth_create_account(opts) opts[:client_id] = self.client_id opts[:client_secret] = self.client_secret HelloSign::Resource::Account.new post('/account/create', { :body => opts }) end |
#oauth_url(state) ⇒ type
Returns the OAuth URL where users can give permission for your application to perform actions on their behalf.
It can be set to the value of your choice (preferably something random). You should verify it matches the expected value when validating the OAuth callback.
45 46 47 |
# File 'lib/hello_sign/api/oauth.rb', line 45 def oauth_url(state) "#{self.oauth_end_point}/oauth/authorize?response_type=code&client_id=#{self.client_id}&state=#{state}" end |
#refresh_oauth_token(opts) ⇒ Hash
Refreshes the user’s OAuth token.
78 79 80 81 82 83 |
# File 'lib/hello_sign/api/oauth.rb', line 78 def refresh_oauth_token(opts) opts[:client_id] = self.client_id opts[:client_secret] = self.client_secret opts[:grant_type] = 'refresh_token' post('/oauth/token', { :body => opts, :oauth_request => true }) end |