Skip to content

Commit

Permalink
Merge pull request #31 from planningcenter/7m/fix-oauth-revoke
Browse files Browse the repository at this point in the history
Don't url-encode params to oauth endpoints
  • Loading branch information
seven1m authored Jul 11, 2024
2 parents b050eea + ad54e63 commit 5cb7506
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.1.2 (July 11, 2024)

- Fix: Don't url-encode parameters to `/oauth` endpoints

# 2.1.1 (April 24, 2024)

- Fix: Tell Faraday to use JSON for the request
Expand Down
16 changes: 2 additions & 14 deletions lib/pco/api/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get(params = {})

def post(body = {})
@last_result = @connection.post(@url) do |req|
req.body = _build_body(body)
req.body = body.to_json
end
_build_response(@last_result)
rescue Errors::TooManyRequests => e
Expand All @@ -61,7 +61,7 @@ def post(body = {})

def patch(body = {})
@last_result = @connection.patch(@url) do |req|
req.body = _build_body(body)
req.body = body.to_json
end
_build_response(@last_result)
rescue Errors::TooManyRequests => e
Expand Down Expand Up @@ -116,18 +116,6 @@ def _build_response(result)
end
end

def _build_body(body)
if _needs_url_encoded?
Faraday::Utils.build_nested_query(body)
else
body.to_json
end
end

def _needs_url_encoded?
@url =~ /oauth\/[a-z]+\z/
end

def _build_endpoint(path)
@cache[path] ||= begin
self.class.new(
Expand Down
2 changes: 1 addition & 1 deletion lib/pco/api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module PCO
module API
VERSION = '2.1.1'
VERSION = '2.1.2'
end
end

0 comments on commit 5cb7506

Please sign in to comment.