Class: OmniAuth::Strategies::QQConnect

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/qq_connect.rb

Instance Method Summary collapse

Instance Method Details

#raw_infoObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/omniauth/strategies/qq_connect.rb', line 27

def raw_info
  @raw_info ||= begin
    access_token.options[:mode] = :query
    access_token.options[:param_name] = :access_token
    # Response Example: "callback( {\"client_id\":\"11111\",\"openid\":\"000000FFFF\"} );\n"
    response = access_token.get('/oauth2.0/me')
    #TODO handle error case
    matched = response.body.match(/"openid":"(?<openid>\w+)"/)
    matched[:openid]
  end
end

#user_infoObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/omniauth/strategies/qq_connect.rb', line 39

def 
  @user_info ||= begin
    #TODO handle error case
    #TODO make info request url configurable
    client.request(:get, "https://graph.qq.com/user/get_user_info", :params => {
        :format => :json,
        :openid => uid,
        :oauth_consumer_key => options[:client_id],
        :access_token => access_token.token
      }, :parse => :json).parsed
  end
end