Class: OmniAuth::Strategies::Weixin
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Weixin
- Defined in:
- lib/omniauth/strategies/weixin.rb
Instance Method Summary collapse
- #authorize_params ⇒ Object
- #build_access_token ⇒ Object
- #raw_info ⇒ Object
- #request_phase ⇒ Object
- #token_params ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/omniauth/strategies/weixin.rb', line 18 def [:scope] = "snsapi_userinfo" if [:scope].nil? { :appid => .client_id, :redirect_uri => callback_url, :response_type => 'code', :scope => [:scope] } end |
#build_access_token ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/omniauth/strategies/weixin.rb', line 34 def build_access_token client.auth_code.get_token( request.params['code'], {:redirect_uri => callback_url, :parse => :json}.merge(token_params.to_hash(:symbolize_keys => true)), {:mode => :query, :param_name => 'access_token'} ) end |
#raw_info ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/omniauth/strategies/weixin.rb', line 62 def raw_info @raw_info ||= begin response = access_token.get( '/sns/userinfo', {:params => {:openid => uid}, :parse => :json} ).parsed end end |
#request_phase ⇒ Object
14 15 16 |
# File 'lib/omniauth/strategies/weixin.rb', line 14 def request_phase redirect client.() + "#wechat_redirect" end |
#token_params ⇒ Object
29 30 31 32 |
# File 'lib/omniauth/strategies/weixin.rb', line 29 def token_params params = super params.merge({:appid => .client_id, :secret => .client_secret}) end |