Skip to content

Commit 7a3593a

Browse files
committed
docs: add OAuth2 scope documentation and changelog
- Document all 20 available OAuth2 scopes in README - Add usage examples for custom scope configuration - Update CHANGELOG with new features - Include descriptions for users.email and media.write scopes
1 parent 919ab57 commit 7a3593a

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
## [Unreleased]
22

3+
### Added
4+
- Added `AVAILABLE_SCOPES` constant with all supported X (Twitter) OAuth 2.0 scopes
5+
- Added `DEFAULT_SCOPE` constant set to "tweet.read users.read"
6+
- Added default `authorize_params` with scope configuration
7+
- Added `authorize_params` method to handle scope validation and defaults
8+
- Added comprehensive documentation for available scopes in README
9+
10+
### Changed
11+
- Scope parameter is now explicitly handled with defaults and validation
12+
313
## [0.1.0] - 2022-01-13
414

515
- Initial release

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,46 @@ $ gem install omniauth-twitter2
3333
```ruby
3434
# config/initializers/omniauth.rb
3535
Rails.application.config.middleware.use OmniAuth::Builder do
36-
provider :twitter2, ENV["TWITTER_CLIENT_ID"], ENV["TWITTER_CLIENT_SECRET"], callback_path: '/auth/twitter2/callback', scope: "tweet.read users.read"
36+
provider :twitter2, ENV["TWITTER_CLIENT_ID"], ENV["TWITTER_CLIENT_SECRET"],
37+
callback_path: '/auth/twitter2/callback',
38+
scope: "tweet.read users.read" # Default scope
39+
end
40+
```
41+
42+
### Available Scopes
43+
44+
The following OAuth 2.0 scopes are available for X (Twitter) API v2:
45+
46+
- `tweet.read` - All the Tweets you can view, including Tweets from protected accounts.
47+
- `tweet.write` - Tweet and Retweet for you.
48+
- `tweet.moderate.write` - Hide and unhide replies to your Tweets.
49+
- `users.email` - Email from an authenticated user.
50+
- `users.read` - Any account you can view, including protected accounts.
51+
- `follows.read` - People who follow you and people who you follow.
52+
- `follows.write` - Follow and unfollow people for you.
53+
- `offline.access` - Stay connected to your account until you revoke access.
54+
- `space.read` - All the Spaces you can view.
55+
- `mute.read` - Accounts you've muted.
56+
- `mute.write` - Mute and unmute accounts for you.
57+
- `like.read` - Tweets you've liked and likes you can view.
58+
- `like.write` - Like and un-like Tweets for you.
59+
- `list.read` - Lists, list members, and list followers of lists you've created or are a member of, including private lists.
60+
- `list.write` - Create and manage Lists for you.
61+
- `block.read` - Accounts you've blocked.
62+
- `block.write` - Block and unblock accounts for you.
63+
- `bookmark.read` - Get Bookmarked Tweets from an authenticated user.
64+
- `bookmark.write` - Bookmark and remove Bookmarks from Tweets.
65+
- `media.write` - Upload media.
66+
67+
Default scope is `"tweet.read users.read"` if not specified.
68+
69+
You can customize the scope like this:
70+
71+
```ruby
72+
Rails.application.config.middleware.use OmniAuth::Builder do
73+
provider :twitter2, ENV["TWITTER_CLIENT_ID"], ENV["TWITTER_CLIENT_SECRET"],
74+
callback_path: '/auth/twitter2/callback',
75+
scope: "tweet.read tweet.write users.read offline.access"
3776
end
3877
```
3978

0 commit comments

Comments
 (0)