Class: OmniAuth::Strategies::Gohighlevel
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Gohighlevel
- Defined in:
- lib/omniauth/gohighlevel.rb
Instance Method Summary collapse
- #authorize_params ⇒ Object
- #build_access_token ⇒ Object
- #callback_phase ⇒ Object
- #callback_url ⇒ Object
- #raw_info ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
66 67 68 69 70 71 |
# File 'lib/omniauth/gohighlevel.rb', line 66 def super.tap do |params| params[:scope] = request.params["scope"] if request.params["scope"] params[:user_type] = "Location" end end |
#build_access_token ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/omniauth/gohighlevel.rb', line 22 def build_access_token verifier = request.params["code"] @token = client.auth_code.get_token( verifier, { redirect_uri: callback_url, client_id: .client_id, client_secret: .client_secret, grant_type: "authorization_code", user_type: "Location" }, {headers: {"Accept" => "application/json"}} ) @token rescue ::OAuth2::Error => e Rails.logger.error "OAuth2 Error: #{e.code} - #{e.description}" Rails.logger.error "Response body: #{e.response.body}" if e.response raise e rescue => e Rails.logger.error "Error during token exchange: #{e.class.name} - #{e.}" Rails.logger.error e.backtrace.join("\n") raise e end |
#callback_phase ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/omniauth/gohighlevel.rb', line 46 def callback_phase if request.params["error"] || request.params["error_reason"] raise CallbackError.new(request.params["error"], request.params["error_description"] || request.params["error_reason"], request.params["error_uri"]) elsif !request.params["code"] fail!(:missing_code, OmniAuth::Error.new("Missing code parameter")) else .token_params["redirect_uri"] = callback_url super end rescue CallbackError => e fail!(:invalid_credentials, e) rescue ::OAuth2::Error, CallbackError => e fail!(:invalid_credentials, e) rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e fail!(:timeout, e) rescue ::SocketError => e fail!(:failed_to_connect, e) end |
#callback_url ⇒ Object
92 93 94 |
# File 'lib/omniauth/gohighlevel.rb', line 92 def callback_url full_host + script_name + callback_path end |
#raw_info ⇒ Object
88 89 90 |
# File 'lib/omniauth/gohighlevel.rb', line 88 def raw_info @raw_info ||= access_token.params.slice("company_id", "location_id", "user_id", "user_type") end |