omniauth-shikimori-oauth2 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea04efed2f5b8f6ca5175c9f2ab0620971c6026a42e41c693a4b0744b7414150
4
- data.tar.gz: 7bdc09bf37f87db1ad37317b072833dc1831a998a4d70c9080fc40190afd2568
3
+ metadata.gz: 3323463948f657ba699ed8db065981532d57fa60e9de125be717123ac97cccaa
4
+ data.tar.gz: ee45c88681bd49327b06c13a176eb283089a14d9553ca733a20683f88ed86f0f
5
5
  SHA512:
6
- metadata.gz: '07392bb0a496168eac6d7c920b681071381feff7e1ebeb4d9d500b344fa48f7aa16bc5e8f47f571c5b4f12d7d3b802e435537f8b2954ac5d192f47f942b8f581'
7
- data.tar.gz: 3efdae723a41f72409328e153f12a97a4927da1935b646c3155ae9f1627b02d49ea779b82a1be1ea4534e84fa63d545165042eff6c616a051e1937cdcd0f8890
6
+ metadata.gz: e593ff414888639fb76f8b97acf4986e0560240691d75ff91ac7da555cc1893d62980c434cfe4d45f69594ac6b859282d7b24a460fc6059c5020f50f6ec356c3
7
+ data.tar.gz: 45dbc3d9b0967a658daae24a0cdaa7e54c14143e89d4b60353eb6c9e0c2f0fb676f4a3c47de294bd087ff814f7c464d75b98ff9cd6ef8335d2af373623c48f42
data/README.md CHANGED
@@ -1,20 +1,293 @@
1
- [![CI](https://github.com/iwdt/shikikit/actions/workflows/main.yml/badge.svg)](https://github.com/iwdt/shikikit/actions/workflows/main.yml) [![codecov](https://codecov.io/gh/iwdt/shikikit/graph/badge.svg)](https://codecov.io/gh/iwdt/shikikit)
2
-
3
1
  # Shikikit
4
- Ruby toolkit for the [Shikimori API](https://shikimori.one)
5
-
6
- ## TODO:
7
- - logger
8
- - #as_app
9
- - proxy config
10
- - oauth methods on API
11
- - optional auto refresh token
12
- - more information at errors
13
- - more tests
14
- - entities for responses
15
- - contracts for requests (client-side validations)
16
- - better documentation
17
- - mutator
18
- - CI/CD
19
- - auto version increment on main branch pushing
20
- - deploy to rubygems
2
+ Ruby toolkit for the [Shikimori](https://shikimori.one)
3
+
4
+ [![Shikimori Profile](https://img.shields.io/badge/shikimori_profile-gray?logo=shikimori)](https://shikimori.one/io.human) [![Codecov](https://img.shields.io/codecov/c/gh/iwdt/shikikit?logo=codecov)](https://codecov.io/gh/iwdt/shikikit) [![CI](https://img.shields.io/github/actions/workflow/status/iwdt/shikikit/main.yml?label=CI&logo=github)](https://github.com/iwdt/shikikit/actions/workflows/main.yml) [![GitHub Discussions](https://img.shields.io/github/discussions/iwdt/shikikit?logo=github)](https://github.com/iwdt/shikikit/discussions)
5
+
6
+
7
+ ## Table of Contents
8
+ 1. [API Documentation](#api-documentation)
9
+ 2. [Omniauth Strategy](#omniauth-shikimori-strategy)
10
+ 1. [Installation](#installation)
11
+ 2. [Configuration](#configuration)
12
+ 3. [Usage](#usage-examples)
13
+ 3. [OAuth2](#shikimori-oauth-2)
14
+ 1. [Installation](#installation-1)
15
+ 2. [Configuration](#configuration-1)
16
+ 3. [Usage](#usage)
17
+ 4. [API Client](#shikimori-api)
18
+ 1. [Installation](#installation-2)
19
+ 3. [Usage](#usage-1)
20
+ 5. [Supported Ruby Versions](#supported-ruby-versions)
21
+ 6. [Versioning](#versioning)
22
+ 7. [Contributing](/CONTRIBUTING.md)
23
+ 8. [Code of conduct](/CODE_OF_CONDUCT.md)
24
+ 9. [License](/LICENSE.txt)
25
+
26
+ ## API Documentation
27
+
28
+ * [Shikimori API](https://www.rubydoc.info/gems/shikimori-api)
29
+ * [Shikimori OAuth2](https://www.rubydoc.info/gems/shikimori-oauth2)
30
+ * [Omniauth Shikimori Strategy](https://www.rubydoc.info/gems/omniauth-shikimori-oauth2)
31
+
32
+ ## Omniauth Shikimori Strategy
33
+
34
+ Strategy to authenticate with Shikimori via OAuth2 in OmniAuth. To use it, you'll need to sign up for an OAuth2 Application ID and Secret on the [Shikimori OAuth Apps Page](https://shikimori.one/oauth/applications).
35
+
36
+ Shikimori's official guide to using OAuth2: https://shikimori.one/oauth
37
+
38
+ [![Gem Version](https://img.shields.io/gem/v/omniauth-shikimori-oauth2?logo=rubygems&label=RubyGems)](https://rubygems.org/gems/omniauth-shikimori-oauth2)
39
+
40
+ ### Installation
41
+
42
+ Add to your `Gemfile`:
43
+
44
+ ```ruby
45
+ gem 'omniauth-shikimori-oauth2', '~> 1.0'
46
+ ```
47
+
48
+ Then `bundle install`
49
+
50
+ ### Configuration
51
+
52
+ You can configure several options, which you pass in to the `provider` method via a `Hash`:
53
+
54
+ * `app_name`: the name of the registered OAuth application at https://shikimori.one/oauth/applications
55
+ > **⚠ WARNING!**
56
+ > This is an important option that must be specified, as otherwise your IP may be banned for further requests to Shikimori.
57
+
58
+ * `scope`: required list of access permissions you want to request from the user. Available values:
59
+ - `user_rates` - modify your list of anime and manga.
60
+ - `messages` - read your personal messages, send personal messages on your behalf.
61
+ - `comments` - comment on behalf of you.
62
+ - `topics` - create topics and reviews on your behalf.
63
+ - `content` - modify the website's database.
64
+ - `clubs` - join and leave clubs.
65
+ - `friends` - add and remove people as friends.
66
+ - `ignores` - add and remove people to ignore.
67
+
68
+ * `client_options`: optional `Hash` of client options. Available options:
69
+ - `site` - the OAuth2 provider site host. Default: `https://shikimori.one`
70
+ - `redirect_uri` - the absolute URI to the Redirection Endpoint for use in authorization grants and token exchange.
71
+ - `authorize_url` - absolute or relative URL path to the Authorization endpoint. Default: `/oauth/authorize`
72
+ - `token_url` - absolute or relative URL path to the Token endpoint. Default: `/oauth/token`
73
+ - `token_method` - HTTP method to use to request token (`:get`, `:post`, `:post_with_query_string`). Default: `:post`
74
+ - `auth_scheme` - HTTP method to use to authorize request (`:basic_auth` or `:request_body`). Default: `:basic_auth`
75
+ - `connection_opts` - `Hash` of connection options to pass to initialize `Faraday` with. Default: `{}`
76
+ - `max_redirects` - maximum number of redirects to follow. Default: `5`
77
+ - `raise_errors` - whether or not to raise an `OAuth2::Error` on responses with 400+ status codes. Default: `true`
78
+ - `logger` - which logger to use when `OAUTH_DEBUG` is enabled. Default: `::Logger.new($stdout)`
79
+
80
+ Here's an example of a possible configuration:
81
+
82
+ ```ruby
83
+ provider :shikimori, ENV['SHIKIMORI_KEY'], ENV['SHIKIMORI_KEY'],
84
+ scope: %w[user_rates messages comments topics content clubs friends ignores],
85
+ app_name: 'My awesome site',
86
+ client_options: {
87
+ site: 'https://shikimori.org',
88
+ redirect_url: 'https://my-awesome-site.example/auth/shikimori/callback',
89
+ logger: Rails.logger
90
+ }
91
+ ```
92
+
93
+ ### Usage examples
94
+ #### Rails usage
95
+ In `config/initializers/omniauth.rb`
96
+
97
+ ```ruby
98
+ Rails.application.config.middleware.use OmniAuth::Builder do
99
+ provider :shikimori, ENV['SHIKIMORI_KEY'], ENV['SHIKIMORI_KEY'],
100
+ scope: %w[user_rates comments topics],
101
+ app_name: ENV['SHIKIMORI_APP_NAME'],
102
+ client_options: {
103
+ redirect_url: 'https://my-awesome-site.example/auth/shikimori/callback',
104
+ logger: Rails.logger
105
+ }
106
+ end
107
+ ```
108
+
109
+ #### Non-rails usage
110
+ Add middleware to your rack-based application:
111
+
112
+ ```ruby
113
+ use OmniAuth::Builder do
114
+ provider :shikimori, ENV['SHIKIMORI_KEY'], ENV['SHIKIMORI_SECRET'],
115
+ scope: %w[user_rates comments topics],
116
+ app_name: ENV['SHIKIMORI_APP_NAME'],
117
+ client_options: {
118
+ redirect_url: 'https://my-awesome-site.example/auth/shikimori/callback'
119
+ }
120
+ end
121
+ ```
122
+
123
+ ## Shikimori OAuth 2
124
+
125
+ A Ruby wrapper for the [Shikimori's OAuth 2](https://shikimori.one/oauth)
126
+
127
+ [![Gem Version](https://img.shields.io/gem/v/shikimori-oauth2?logo=rubygems&label=RubyGems)](https://rubygems.org/gems/shikimori-oauth2)
128
+
129
+
130
+ ### Installation
131
+
132
+ Install via Rubygems
133
+
134
+ ```bash
135
+ gem install shikimori-oauth2
136
+ ```
137
+
138
+ ... or add to your Gemfile
139
+
140
+ ```ruby
141
+ gem 'shikimori-oauth2', '~> 1.0'
142
+ ```
143
+
144
+ Access the library in Ruby:
145
+
146
+ ```ruby
147
+ require 'shikimori-oauth2'
148
+ ```
149
+
150
+ ### Configuration
151
+
152
+ While `Shikimori::OAuth2::Client` accepts a range of options when creating a new client instance, Shikimori's configuration API allows you to set your configuration options at the module level. This is particularly handy if you're creating a number of client instances based on some shared defaults. Changing options affects new instances only and will not modify existing `Shikimori::OAuth2::Client` instances created with previous options.
153
+
154
+ Configuring module defaults
155
+
156
+ Every writable attribute in `Shikimori::OAuth2::Config` can be set in batch:
157
+
158
+ ```ruby
159
+ Shikimori::Oauth2.configure do |c|
160
+ c.site = 'https://shikimori.one/'
161
+ c.app_name = 'My awesome site'
162
+ c.options = {
163
+ redirect_uri: 'https://my-awesome-site.example/auth/shikimori/callback',
164
+ authorize_url: '/oauth/authorize',
165
+ token_url: '/oauth/token',
166
+ token_method: :post,
167
+ auth_scheme: :basic_auth,
168
+ connection_opts: {},
169
+ max_redirects: 5,
170
+ raise_errors: true,
171
+ logger: ::Logger.new($stdout),
172
+ }
173
+ end
174
+ ```
175
+
176
+ Also available global options from [OAuth2 gem](https://gitlab.com/oauth-xx/oauth2#global-configuration).
177
+
178
+ ### Usage
179
+
180
+ To get access and refresh tokens, follow this example:
181
+
182
+ ```ruby
183
+ require 'shikimori-oauth2'
184
+
185
+ client = Shikimori::OAuth2::Client.new('client_id', 'client_secret', app_name: 'Api test')
186
+ client.auth_code.authorize_url(scope: 'user_rates+comments+topics', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
187
+ #=> https://shikimori.one/oauth/authorize?client_id=client_id&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=user_rates+comments+topics
188
+ #=> Open this link at browser and copy code
189
+
190
+ access = client.auth_code.get_token('authorization_code_value', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
191
+
192
+ access.token #=> Access token
193
+ access.refresh_token #=> Refresh token
194
+ access.expires_in #=> 86400
195
+ access.expires_at #=> 1708887613
196
+ ```
197
+
198
+ ## Shikimori API
199
+
200
+ Simple wrapper for the Shikimori API
201
+
202
+ [![Gem Version](https://img.shields.io/gem/v/shikimori-api?logo=rubygems&label=RubyGems)](https://rubygems.org/gems/shikimori-api)
203
+
204
+ ### Installation
205
+
206
+ Install via Rubygems
207
+
208
+ ```bash
209
+ gem install shikimori-api
210
+ ```
211
+
212
+ ... or add to your Gemfile
213
+
214
+ ```ruby
215
+ gem 'shikimori-api', '~> 1.0'
216
+ ```
217
+
218
+ Access the library in Ruby:
219
+
220
+ ```ruby
221
+ require 'shikimori-api'
222
+ ```
223
+
224
+ ### Usage
225
+
226
+ API methods are accessible as instance methods of the `Shikimori::API::Client`. Documentation is available at RubyDoc.info:
227
+ * [V1 methods](https://www.rubydoc.info/gems/shikimori-api/Shikimori/API/V1)
228
+ * [V2 methods](https://www.rubydoc.info/gems/shikimori-api/Shikimori/API/V2)
229
+
230
+ ### Examples
231
+
232
+ Basic example to get 10 random anime titles released in the 90s
233
+
234
+ ```ruby
235
+ client = Shikimori::API::Client.new
236
+ client.v1.animes(limit: 10, order: 'random', season: '199x') # call /api/animes
237
+ ```
238
+
239
+ To provide authentication credentials, you can pass them as arguments during client initialization:
240
+
241
+ ```ruby
242
+ access_token = 'access_token' #=> User's access token
243
+ refresh_token = 'refresh_token' #=> User's refresh token
244
+ oauth_app_name = 'Api Test' #=> OAuth2 application name
245
+
246
+ client = Shikimori::API::Client.new(app_name: oauth_app_name, access_token: access_token, refresh_token: refresh_token)
247
+ client.v1.whoami
248
+ ```
249
+
250
+ For passing additional query parameters to request use the following syntax:
251
+
252
+ ```ruby
253
+ client.v1.animes(limit: 10, page: 2, another_param: 'Param')
254
+ client.v1.anime_videos(anime_id, first_param: 1, second_param: 2)
255
+ ```
256
+
257
+ ... and for request headers use the following syntax:
258
+
259
+ ```ruby
260
+ client.v1.animes(headers: { 'X-Header-Name' => 'My header value' })
261
+ ```
262
+
263
+ For configuring a connection through proxy, you can pass `proxy_host`, `proxy_port`, `proxy_user` and `proxy_password` as arguments during client initialization:
264
+
265
+ ```ruby
266
+ client = Shikimori::API::Client.new(proxy_host: 'http://my-proxy', proxy_port: 8080, proxy_user: 'my_proxy_user', proxy_password: 'my_proxy_password')
267
+ ```
268
+
269
+ You can also using client as application:
270
+
271
+ ```ruby
272
+ Shikimori::API::Client.as_app(access_token: 'access-token') do |client|
273
+ animes = client.animes
274
+ mangas = client.mangas
275
+ # some logic ...
276
+ end
277
+ ```
278
+
279
+ ## Supported Ruby Versions
280
+ This library aims to support and is tested against the following Ruby implementations:
281
+ * Ruby 3.0
282
+ * Ruby 3.1
283
+ * Ruby 3.2
284
+ * Ruby 3.3
285
+
286
+ If something doesn't work on one of these Ruby versions, it's a bug.
287
+
288
+ This library may inadvertently work (or seem to work) on other Ruby implementations, but support will only be provided for the versions listed above.
289
+
290
+ If you would like this library to support another Ruby version, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped.
291
+
292
+ ## Versioning
293
+ This library aims to adhere to [Semantic Versioning 2.0.0](http://semver.org/). Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.
@@ -3,6 +3,6 @@
3
3
  module OmniAuth
4
4
  module Shikimori
5
5
  # @return [String] Semantic version of library
6
- VERSION = '1.0.0'
6
+ VERSION = '1.0.2'
7
7
  end
8
8
  end
@@ -14,11 +14,9 @@ Gem::Specification.new do |spec|
14
14
  spec.license = 'MIT'
15
15
  spec.required_ruby_version = '>= 3.0'
16
16
 
17
- spec.metadata['homepage_uri'] = spec.homepage
18
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
18
  spec.metadata['source_code_uri'] = 'https://github.com/iwdt/shikikit'
20
19
  spec.metadata['bug_tracker_uri'] = 'https://github.com/iwdt/shikikit/issues'
21
- spec.metadata['changelog_uri'] = 'https://github.com/iwdt/shikikit/blob/main/CHANGELOG.md'
22
20
  spec.metadata['rubygems_mfa_required'] = 'true'
23
21
 
24
22
  spec.files = Dir[
@@ -37,5 +35,5 @@ Gem::Specification.new do |spec|
37
35
  spec.require_paths = ['lib']
38
36
 
39
37
  spec.add_dependency 'omniauth-oauth2', '~> 1.8'
40
- spec.add_dependency 'shikimori-oauth2', '~> 1.0.0'
38
+ spec.add_dependency 'shikimori-oauth2', '~> 1.0'
41
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-shikimori-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Naumov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-22 00:00:00.000000000 Z
11
+ date: 2025-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0
40
+ version: '1.0'
41
41
  description: Strategy to authenticate with Shikimori via OAuth2 in OmniAuth.
42
42
  email:
43
43
  - ivannaymov@gmail.com
@@ -59,11 +59,9 @@ homepage: https://github.com/iwdt/shikikit
59
59
  licenses:
60
60
  - MIT
61
61
  metadata:
62
- homepage_uri: https://github.com/iwdt/shikikit
63
62
  allowed_push_host: https://rubygems.org
64
63
  source_code_uri: https://github.com/iwdt/shikikit
65
64
  bug_tracker_uri: https://github.com/iwdt/shikikit/issues
66
- changelog_uri: https://github.com/iwdt/shikikit/blob/main/CHANGELOG.md
67
65
  rubygems_mfa_required: 'true'
68
66
  post_install_message:
69
67
  rdoc_options: []
@@ -80,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
78
  - !ruby/object:Gem::Version
81
79
  version: '0'
82
80
  requirements: []
83
- rubygems_version: 3.0.3.1
81
+ rubygems_version: 3.2.33
84
82
  signing_key:
85
83
  specification_version: 4
86
84
  summary: OmnAuth strategy for Shikimori