class SimpleWechat::AuthClient
Attributes
appid[R]
secret[R]
Public Class Methods
new(appid, secret)
click to toggle source
# File lib/simple_wechat/auth_client.rb, line 18 def initialize(appid, secret) @appid, @secret = appid, secret end
Public Instance Methods
connection()
click to toggle source
# File lib/simple_wechat/auth_client.rb, line 32 def connection @connection ||= begin conn = Faraday.new do |faraday| faraday.adapter Faraday.default_adapter end end end
get_token(code)
click to toggle source
# File lib/simple_wechat/auth_client.rb, line 27 def get_token(code) response = connection.get("https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{appid}&secret=#{secret}&code=#{code}&grant_type=authorization_code") access_token = AccessToken.new MultiJson.load(response.body) end