Class: OmniAuth::Strategies::Wechat
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Wechat
- Defined in:
- lib/omniauth/strategies/wechat.rb
Instance Method Summary collapse
Instance Method Details
#callback_url ⇒ Object
19 20 21 |
# File 'lib/omniauth/strategies/wechat.rb', line 19 def callback_url full_host + script_name + callback_path end |
#raw_info ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/omniauth/strategies/wechat.rb', line 49 def raw_info @uid ||= access_token["openid"] @raw_info ||= begin access_token.[:mode] = :query if access_token["scope"] == "snsapi_userinfo" response = access_token.get("/sns/userinfo", :params => {"openid" => @uid, "lang" => "zh_CN"}, parse: :text) @raw_info = JSON.parse(response.body.gsub(/[\u0000-\u001f]+/, '')) else @raw_info = {"openid" => @uid } @raw_info.merge!("unionid" => access_token["unionid"]) if access_token["unionid"] @raw_info end end end |
#request_phase ⇒ Object
42 43 44 45 46 47 |
# File 'lib/omniauth/strategies/wechat.rb', line 42 def request_phase params = client.auth_code..merge() params["appid"] = params.delete("client_id") params["redirect_uri"] = callback_url redirect client.(params) end |