Class: Mautic::Connections::Oauth2
- Inherits:
-
Mautic::Connection
- Object
- ActiveRecord::Base
- ApplicationRecord
- Mautic::Connection
- Mautic::Connections::Oauth2
- Defined in:
- app/models/mautic/connections/oauth2.rb
Instance Method Summary collapse
- #authorize ⇒ Object
- #client ⇒ Object
- #connection ⇒ Object
- #get_code(code) ⇒ Object
- #refresh! ⇒ Object
- #request(type, path, params = {}) ⇒ Object
Methods inherited from Mautic::Connection
Instance Method Details
#authorize ⇒ Object
14 15 16 |
# File 'app/models/mautic/connections/oauth2.rb', line 14 def client.auth_code.(redirect_uri: callback_url) end |
#client ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'app/models/mautic/connections/oauth2.rb', line 5 def client @client ||= OAuth2::Client.new(client_id, secret, { site: url, authorize_url: 'oauth/v2/authorize', token_url: 'oauth/v2/token', raise_errors: false }) end |
#connection ⇒ Object
22 23 24 |
# File 'app/models/mautic/connections/oauth2.rb', line 22 def connection @connection ||= OAuth2::AccessToken.new(client, token, { refresh_token: refresh_token }) end |
#get_code(code) ⇒ Object
18 19 20 |
# File 'app/models/mautic/connections/oauth2.rb', line 18 def get_code(code) client.auth_code.get_token(code, redirect_uri: callback_url) end |
#refresh! ⇒ Object
26 27 28 29 30 |
# File 'app/models/mautic/connections/oauth2.rb', line 26 def refresh! @connection = connection.refresh! update(token: @connection.token, refresh_token: @connection.refresh_token) @connection end |
#request(type, path, params = {}) ⇒ Object
32 33 34 35 36 |
# File 'app/models/mautic/connections/oauth2.rb', line 32 def request(type, path, params = {}) @last_request = [type, path, params] response = connection.request(type, path, params) parse_response(response) end |