You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82Lines changed: 82 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -683,6 +683,18 @@ using various class methods including the standard new, `from_hash` (if you have
683
683
a hash of the values), or `from_kvform` (if you have an
684
684
`application/x-www-form-urlencoded` encoded string of the values).
685
685
686
+
Options (since v2.0.x unless noted):
687
+
- expires_latency (Integer | nil): Seconds to subtract from expires_in when computing #expired? to offset latency.
688
+
- token_name (String | Symbol | nil): When multiple token-like fields exist in responses, select the field name to use as the access token (since v2.0.10).
689
+
- mode (Symbol | Proc | Hash): Controls how the token is transmitted on requests made via this AccessToken instance.
690
+
-:header — Send as Authorization: Bearer <token> header (default and preferred by OAuth 2.1 draft guidance).
691
+
-:query — Send as access_token query parameter (discouraged in general, but required by some providers).
692
+
- Verb-dependent (since v2.0.15): Provide either:
693
+
- a Proc taking |verb| and returning :header or :query, or
694
+
- a Hash with verb symbols as keys, for example: {get: :query, post: :header, delete: :header}.
695
+
696
+
Note: Verb-dependent mode was added in v2.0.15 to support providers like Instagram that require query mode for GET and header mode for POST/DELETE.
697
+
686
698
### OAuth2::Error
687
699
688
700
On 400+ status code responses, an `OAuth2::Error` will be raised. If it is a
@@ -852,6 +864,76 @@ Notes:
852
864
853
865
</details>
854
866
867
+
### Instagram API (verb‑dependent token mode)
868
+
869
+
Providers like Instagram require the access token to be sent differently depending on the HTTP verb:
870
+
- GET requests: token must be in the query string (?access_token=...)
871
+
- POST/DELETE requests: token must be in the Authorization header (Bearer ...)
872
+
873
+
Since v2.0.15, you can configure an AccessToken with a verb‑dependent mode. The gem will choose how to send the token based on the request method.
874
+
875
+
Example: exchanging and refreshing long‑lived Instagram tokens, and making API calls
876
+
877
+
```ruby
878
+
require"oauth2"
879
+
880
+
# NOTE: Users authenticate via Facebook Login to obtain a short‑lived user token (not shown here).
881
+
# See Facebook Login docs for obtaining the initial short‑lived token.
0 commit comments