Class: OmniAuth::Strategies::Glitch
- Defined in:
- lib/omniauth/strategies/oauth2/glitch.rb
Instance Attribute Summary
Attributes inherited from OAuth2
#client_id, #client_options, #client_secret, #options
Instance Method Summary collapse
- #auth_hash ⇒ Object
-
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Glitch
constructor
A new instance of Glitch.
- #user_data ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth2
Constructor Details
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Glitch
Returns a new instance of Glitch.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/omniauth/strategies/oauth2/glitch.rb', line 7 def initialize(app, client_id=nil, client_secret=nil, ={}, &block) # :scope (identity|read|write) is required for authorization and should be passed # in the OmniAuth :provider options hash in your application = { :site => 'http://api.glitch.com', :authorize_url => '/oauth2/authorize', :token_url => '/oauth2/token' } super(app, :glitch, client_id, client_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/omniauth/strategies/oauth2/glitch.rb', line 20 def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['player_tsid'], 'user_info' => user_info, 'extra' => user_data, } ) end |
#user_data ⇒ Object
30 31 32 33 34 |
# File 'lib/omniauth/strategies/oauth2/glitch.rb', line 30 def user_data @access_token..merge!({:param_name => 'oauth_token', :mode => :query}) response = @access_token.post('/simple/players.info') @data ||= MultiJson.decode(response.body) end |
#user_info ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/omniauth/strategies/oauth2/glitch.rb', line 36 def user_info { 'name' => user_data['user_name'], 'nickname' => user_data['player_name'], 'image' => user_data['avatar_url'], } end |