Class: OmniAuth::Strategies::Glitch

Inherits:
OAuth2
  • Object
show all
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

Methods inherited from OAuth2

#callback_url, #client

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, options={}, &block)

  # :scope (identity|read|write) is required for authorization and should be passed
  # in the OmniAuth :provider options hash in your application

  client_options = {
    :site => 'http://api.glitch.com',
    :authorize_url => '/oauth2/authorize',
    :token_url => '/oauth2/token'
  }
  super(app, :glitch, client_id, client_secret, client_options, options, &block)
end

Instance Method Details

#auth_hashObject



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' => ,
      'extra' => user_data,
    }
  )
end

#user_dataObject



30
31
32
33
34
# File 'lib/omniauth/strategies/oauth2/glitch.rb', line 30

def user_data
  @access_token.options.merge!({:param_name => 'oauth_token', :mode => :query})
  response = @access_token.post('/simple/players.info')
  @data ||= MultiJson.decode(response.body)
end

#user_infoObject



36
37
38
39
40
41
42
# File 'lib/omniauth/strategies/oauth2/glitch.rb', line 36

def 
  {
    'name' => user_data['user_name'],
    'nickname' => user_data['player_name'],
    'image' => user_data['avatar_url'],
  }
end