module OmniAuth module Strategies class QQ < OmniAuth::Strategies::OAuth2 option :client_options, { site: 'https://graph.qq.com', authorize_url: '/oauth2.0/authorize', token_url: '/oauth2.0/token' } def request_phase super end def authorize_params super.tap do |params| %w[scope client_options].each do |v| if request.params[v] params[v.to_sym] = request.params[v] end end end end uid { raw_info['openid'].to_s } info do { name: user_info['nickname'], nickname: user_info['nickname'], image: user_info['figureurl_qq_1'] } end extra do { raw_info: user_info } end def raw_info access_token.options[:mode] = :query @raw_info ||= access_token.get('/oauth2.0/me').parsed end def user_info access_token.options[:mode] = :query params = { oauth_consumer_key: options.client_id, openid: raw_info['openid'], format: 'json' } @user_info ||= access_token.get('/user/get_user_info', params: params) end end end end