From b55adf18ffc19efef70b9e9e4fbd2309fc80bd36 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Thu, 4 Jan 2024 11:24:43 -0500 Subject: [PATCH] fix param building --- lib/nylas/resources/auth.rb | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/lib/nylas/resources/auth.rb b/lib/nylas/resources/auth.rb index ff01b559..3d3e66e0 100644 --- a/lib/nylas/resources/auth.rb +++ b/lib/nylas/resources/auth.rb @@ -158,32 +158,17 @@ def build_query(config) "access_type" => config[:access_type] || "online", "response_type" => "code" } - set_params(config) - - URI.encode_www_form(params) - end - - # Set the parameters for the query - def set_params(config) params["provider"] = config[:provider] if config[:provider] - set_config_params(config) - set_more_config(config) - end - - # Set login related configurations - def set_config_params(config) + params["prompt"] = config[:prompt] if config[:prompt] + params["metadata"] = config[:metadata] if config[:metadata] + params["state"] = config[:state] if config[:state] + params["scope"] = config[:scope].join(" ") if config[:scope] if config[:login_hint] params["login_hint"] = config[:login_hint] params["include_grant_scopes"] = config[:include_grant_scopes].to_s if config[:include_grant_scopes] end - params["scope"] = config[:scope].join(" ") if config[:scope] - end - # More config - def set_more_config(config) - params["prompt"] = config[:prompt] if config[:prompt] - params["metadata"] = config[:metadata] if config[:metadata] - params["state"] = config[:state] if config[:state] + URI.encode_www_form(params) end # Hashes the secret for PKCE authentication.