From 7660ac3b8830796e232351ec7cff9f1087f7e856 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:05:32 -0500 Subject: [PATCH 1/2] Encode URL params only after all params are set --- lib/nylas/resources/auth.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/nylas/resources/auth.rb b/lib/nylas/resources/auth.rb index e2ed1a51..db806f70 100644 --- a/lib/nylas/resources/auth.rb +++ b/lib/nylas/resources/auth.rb @@ -107,7 +107,7 @@ def revoke(token) # Builds the query with admin consent authentication for Microsoft. # # @param config [Hash] Configuration for the query. - # @return [Array(Hash, String)] Updated list of parameters, including those specific to admin + # @return [String] Updated list of parameters, including those specific to admin # consent. def build_query_with_admin_consent(config) params = build_query(config) @@ -116,14 +116,14 @@ def build_query_with_admin_consent(config) params["response_type"] = "adminconsent" params["credential_id"] = config["credentialId"] - params + URI.encode_www_form(params) end # Builds the query with PKCE. # # @param config [Hash] Configuration for the query. # @param secret_hash [Hash] Hashed secret. - # @return [Array(Hash, String)] Updated list of encoded parameters, including those specific + # @return [String] Updated list of encoded parameters, including those specific # to PKCE. def build_query_with_pkce(config, secret_hash) params = build_query(config) @@ -138,11 +138,11 @@ def build_query_with_pkce(config, secret_hash) # Builds the authentication URL. # # @param config [Hash] Configuration for the query. - # @return [Array(Hash, String)] List of components for the authentication URL. + # @return [URI] List of components for the authentication URL. def url_auth_builder(config) builder = URI.parse(api_uri) builder.path = "/v3/connect/auth" - builder.query = build_query(config) + builder.query = URI.encode_www_form(build_query(config)) builder end @@ -150,7 +150,7 @@ def url_auth_builder(config) # Builds the query. # # @param config [Hash] Configuration for the query. - # @return [Array(Hash, String)] List of encoded parameters for the query. + # @return [Hash] List of parameters to encode in the query. def build_query(config) params = { "client_id" => config[:client_id], @@ -168,7 +168,7 @@ def build_query(config) params["include_grant_scopes"] = config[:include_grant_scopes].to_s if config[:include_grant_scopes] end - URI.encode_www_form(params) + params end # Hash a plain text secret for use in PKCE. From 70ece9f7b5a19aa32a620f531a2693e6c2861905 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:05:59 -0500 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 440edf93..e57e9520 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 6.0.0-beta.4 / TBD * Fixed list and find scheduled messages * Fixed incorrect PKCE code challenge generation +* Fixed incompatible types when building OAuth2 URL ### 6.0.0-beta.3 / 2024-01-04 * **BREAKING CHANGE**: Moved grants API out of `Auth` to `NylasClient`