Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incompatible types when building OAuth2 URL #453

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
14 changes: 7 additions & 7 deletions lib/nylas/resources/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -138,19 +138,19 @@ 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

# 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],
Expand All @@ -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.
Expand Down
Loading