Class: Shikimori::OAuth2::Client
- Inherits:
-
OAuth2::Client
- Object
- OAuth2::Client
- Shikimori::OAuth2::Client
- Defined in:
- lib/shikimori/oauth2/client.rb
Overview
Client for Shikimori OAuth2
Constant Summary collapse
- SCOPE_JOIN_SYMBOL =
'+'
- SCOPE_JOIN_ENCODED_SYMBOL =
'%2B'
Instance Method Summary collapse
- #authorize_url(params = {}) ⇒ Object
- #config ⇒ Object
- #get_token(params, access_token_opts = {}, extract_access_token = nil, &block) ⇒ Object
-
#initialize(client_id, client_secret, options = {}, app_name: config.app_name, &block) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(client_id, client_secret, options = {}, app_name: config.app_name, &block) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/shikimori/oauth2/client.rb', line 10 def initialize( client_id, client_secret, = {}, app_name: config.app_name, &block ) = config..merge() @app_name = app_name super(client_id, client_secret, , &block) end |
Instance Method Details
#authorize_url(params = {}) ⇒ Object
24 25 26 27 |
# File 'lib/shikimori/oauth2/client.rb', line 24 def (params = {}) # Shikimori only works with `+` sign, not encoded value super(params).gsub(SCOPE_JOIN_ENCODED_SYMBOL, SCOPE_JOIN_SYMBOL) end |
#config ⇒ Object
36 37 38 |
# File 'lib/shikimori/oauth2/client.rb', line 36 def config @config ||= OAuth2.config end |
#get_token(params, access_token_opts = {}, extract_access_token = nil, &block) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/shikimori/oauth2/client.rb', line 29 def get_token(params, access_token_opts = {}, extract_access_token = nil, &block) params[:headers] ||= {} params[:headers]['User-Agent'] ||= @app_name super(params, access_token_opts, extract_access_token, &block) end |