Skip to content
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
2 changes: 1 addition & 1 deletion .rubocop_gradual.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
[69, 15, 38, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1480816240],
[79, 13, 23, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 2314399065]
],
"spec/oauth2/client_spec.rb:292714281": [
"spec/oauth2/client_spec.rb:2143306493": [
[6, 1, 29, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/client*_spec.rb`.", 439549885],
[175, 7, 492, "RSpec/NoExpectationExample: No expectation found in this example.", 1272021224],
[194, 7, 592, "RSpec/NoExpectationExample: No expectation found in this example.", 3428877205],
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- improved documentation by @pboling
- Document Mutual TLS (mTLS) usage with example in README (connection_opts.ssl client_cert/client_key and auth_scheme: :tls_client_auth)
- Document usage of flat query params using Faraday::FlatParamsEncoder, with example URI, in README
- Spec: verify flat params are preserved with Faraday::FlatParamsEncoder (skips on Faraday without FlatParamsEncoder)
- documentation notes in code comments and README highlighting OAuth 2.1 differences, with references, such as:
- PKCE required for auth code,
- exact redirect URI match,
Expand Down
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,48 @@ client = OAuth2::Client.new(
end
```

##### Using flat query params (Faraday::FlatParamsEncoder)

Some APIs expect repeated key parameters to be sent as flat params rather than arrays. Faraday provides FlatParamsEncoder for this purpose. You can configure the oauth2 client to use it when building requests.

```ruby
require "faraday"

client = OAuth2::Client.new(
id,
secret,
site: "https://api.example.com",
# Pass Faraday connection options to make FlatParamsEncoder the default
connection_opts: {
request: {params_encoder: Faraday::FlatParamsEncoder},
},
) do |faraday|
faraday.request(:url_encoded)
faraday.adapter(:net_http)
end

access = client.client_credentials.get_token

# Example of a GET with two flat filter params (not an array):
# Results in: ?filter=order.clientCreatedTime%3E1445006997000&filter=order.clientCreatedTime%3C1445611797000
resp = access.get(
"/v1/orders",
params: {
# Provide the values as an array; FlatParamsEncoder expands them as repeated keys
filter: [
"order.clientCreatedTime>1445006997000",
"order.clientCreatedTime<1445611797000",
],
},
)
```

If you instead need to build a raw Faraday connection yourself, the equivalent configuration is:

```ruby
conn = Faraday.new("https://api.example.com", request: {params_encoder: Faraday::FlatParamsEncoder})
```

#### Redirection

The library follows up to `max_redirects` (default 5).
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2.html
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ <h3 class="signature first" id="configure-class_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/AccessToken.html
Original file line number Diff line number Diff line change
Expand Up @@ -3069,7 +3069,7 @@ <h3 class="signature " id="to_hash-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Authenticator.html
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ <h3 class="signature first" id="apply-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Client.html
Original file line number Diff line number Diff line change
Expand Up @@ -2656,7 +2656,7 @@ <h3 class="signature " id="token_url-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Error.html
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ <h3 class="signature " id="response-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/FilteredAttributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ <h3 class="signature first" id="inspect-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/FilteredAttributes/ClassMethods.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ <h3 class="signature " id="filtered_attributes-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Response.html
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ <h3 class="signature " id="status-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Strategy.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h2>Defined Under Namespace</h2>
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Strategy/Assertion.html
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ <h3 class="signature " id="get_token-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Strategy/AuthCode.html
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ <h3 class="signature " id="get_token-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Strategy/Base.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ <h3 class="signature first" id="initialize-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Strategy/ClientCredentials.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ <h3 class="signature " id="get_token-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Strategy/Implicit.html
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ <h3 class="signature " id="get_token-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Strategy/Password.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ <h3 class="signature " id="get_token-instance_method">
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/OAuth2/Version.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ <h2>
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ <h2>Namespace Listing A-Z</h2>
</div>

<div id="footer">
Generated on Sun Aug 31 04:29:07 2025 by
Generated on Sun Aug 31 04:57:43 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
5 changes: 4 additions & 1 deletion docs/file.CHANGELOG.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ <h2 id="unreleased"><a href="https://gitlab.com/ruby-oauth/oauth2/-/compare/v2.0
<h3 id="added">Added</h3>
<ul>
<li>improved documentation by @pboling</li>
<li>Document Mutual TLS (mTLS) usage with example in README (connection_opts.ssl client_cert/client_key and auth_scheme: :tls_client_auth)</li>
<li>Document usage of flat query params using Faraday::FlatParamsEncoder, with example URI, in README</li>
<li>Spec: verify flat params are preserved with Faraday::FlatParamsEncoder (skips on Faraday without FlatParamsEncoder)</li>
<li>documentation notes in code comments and README highlighting OAuth 2.1 differences, with references, such as:
<ul>
<li>PKCE required for auth code,</li>
Expand Down Expand Up @@ -1245,7 +1248,7 @@ <h2 id="001---2010-04-22">
</div></div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:43 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/file.CITATION.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</div></div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/file.CODE_OF_CONDUCT.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ <h2 id="attribution">Attribution</h2>
</div></div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:43 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/file.CONTRIBUTING.html
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ <h4 id="manual-process">Manual process</h4>
</div></div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/file.FUNDING.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h1 id="another-way-to-support-open-source-software">Another Way to Support Open
</div></div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/file.LICENSE.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<div id="content"><div id='filecontents'>MIT License<br><br>Copyright (c) 2017-2025 Peter H. Boling, of Galtzo.com, and oauth2 contributors<br>Copyright (c) 2011-2013 Michael Bleigh and Intridea, Inc.<br><br>Permission is hereby granted, free of charge, to any person obtaining a copy<br>of this software and associated documentation files (the "Software"), to deal<br>in the Software without restriction, including without limitation the rights<br>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br>copies of the Software, and to permit persons to whom the Software is<br>furnished to do so, subject to the following conditions:<br><br>The above copyright notice and this permission notice shall be included in all<br>copies or substantial portions of the Software.<br><br>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br>SOFTWARE.</div></div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/file.OIDC.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ <h2 id="raw-oidc-with-ruby-oauthoauth2">Raw OIDC with ruby-oauth/oauth2</h2>
</div></div>

<div id="footer">
Generated on Sun Aug 31 04:29:08 2025 by
Generated on Sun Aug 31 04:57:44 2025 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.4.5).
</div>
Expand Down
Loading
Loading