Class: OmniAuth::Strategies::Baidu

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

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject

You can pass display, with_offical_account or state params to the auth request, if you need to set them dynamically. You can also set these options in the OmniAuth config :authorize_params option.

/auth/baidu?display=mobile&with_offical_account=1



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/omniauth/strategies/baidu.rb', line 53

def authorize_params
  super.tap do |params|
    %w[display with_offical_account state forcelogin].each do |v|
      if request.params[v]
        params[v.to_sym] = request.params[v]

        # to support omniauth-oauth2's auto csrf protection
        session['omniauth.state'] = params[:state] if v == 'state'
      end
    end
  end
end

#raw_infoObject



39
40
41
42
43
44
# File 'lib/omniauth/strategies/baidu.rb', line 39

def raw_info
  access_token.options[:mode] = :query
  access_token.options[:param_name] = 'access_token'
  @uid ||= access_token.get('/rest/2.0/passport/users/getLoggedInUser').parsed["uid"]
  @raw_info ||= access_token.get("/rest/2.0/passport/users/getInfo", :params => {:uid => @uid}).parsed
end