Class: OmniAuth::Strategies::Wechat

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

Instance Method Summary collapse

Instance Method Details

#raw_infoObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/omniauth/strategies/wechat.rb', line 49

def raw_info
  @uid ||= access_token["openid"]
  @raw_info ||= begin
    access_token.options[:mode] = :query
    if access_token["scope"] == "snsapi_userinfo"
      @raw_info = access_token.get("/sns/userinfo", :params => {"openid" => @uid}, parse: :json).parsed
    else
      @raw_info = {"openid" => @uid }
    end
  end
end

#request_phaseObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/omniauth/strategies/wechat.rb', line 38

def request_phase
  hash_key = request.params['hash_key']

  new_callback_url = "#{callback_url}?hash_key=#{hash_key}"

  params = client.auth_code.authorize_params.merge(redirect_uri: new_callback_url).merge(authorize_params)
  params["appid"] = params.delete("client_id")

  redirect client.authorize_url(params)
end