Class: OmniAuth::Strategies::WeChat
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::WeChat
- Defined in:
- lib/omniauth/strategies/wechat.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
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/omniauth/strategies/wechat.rb', line 16 def params = super params[:state]=request.params['state'] session['omniauth.state'] = params[:state] {:appid=>.client_id, :redirect_uri => callback_url, :response_type => 'code', :status => params[:state] } end |
#build_access_token ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/omniauth/strategies/wechat.rb', line 32 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
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/omniauth/strategies/wechat.rb', line 60 def raw_info @raw_info ||= begin response = access_token.get( '/sns/userinfo', {:params => {:openid => uid, :lang =>'zh-CN'}, :parse => :json} ).parsed end end |
#request_phase ⇒ Object
13 14 15 |
# File 'lib/omniauth/strategies/wechat.rb', line 13 def request_phase redirect client.auth_code.()+'#wechat_redirect' end |
#token_params ⇒ Object
27 28 29 30 |
# File 'lib/omniauth/strategies/wechat.rb', line 27 def token_params params = super params.merge({:appid=>.client_id,:secret=>.client_secret}) end |