class OmniAuth::Strategies::Dingding
Public Instance Methods
raw_info()
click to toggle source
# File lib/omniauth/strategies/dingding.rb, line 44 def raw_info return persistent_code if persistent_code['errcode'] != 0 return sns_token if sns_token['errcode'] != 0 user_info end
request_phase()
click to toggle source
# File lib/omniauth/strategies/dingding.rb, line 38 def request_phase params = client.auth_code.authorize_params.merge(redirect_uri: callback_url).merge(authorize_params) params['appid'] = params.delete('client_id') redirect scan_code_or_account_verify(client.authorize_url(params)) end
Protected Instance Methods
build_access_token()
click to toggle source
# File lib/omniauth/strategies/dingding.rb, line 52 def build_access_token params = { 'appid' => client.id, 'appsecret' => client.secret } client.get_token(params) end
persistent_code()
click to toggle source
# File lib/omniauth/strategies/dingding.rb, line 60 def persistent_code @persistent_code ||= access_token.post(options.client_options.persistent_url + "?access_token=#{access_token.token}") do |req| req.headers['Content-Type'] = 'application/json' req.body = "{\"tmp_auth_code\":\"#{request.params['code']}\"}" end.parsed end
scan_code_or_account_verify(url)
click to toggle source
# File lib/omniauth/strategies/dingding.rb, line 82 def scan_code_or_account_verify(url) url.sub!('/:placeholder', UserAgent.parse(request.env['HTTP_USER_AGENT']).mobile? ? options.client_options.account_authorize_url : options.client_options.scan_code_authorize_url) end
sns_token()
click to toggle source
# File lib/omniauth/strategies/dingding.rb, line 68 def sns_token @sns_token ||= access_token.post(options.client_options.sns_token + "?access_token=#{access_token.token}") do |req| req.headers['Content-Type'] = 'application/json' req.body = "{\"openid\":\"#{@persistent_code['openid']}\", \"persistent_code\":\"#{@persistent_code['persistent_code']}\"}" end.parsed end
user_info()
click to toggle source
# File lib/omniauth/strategies/dingding.rb, line 77 def user_info @user_info ||= access_token.get(options.client_options.user_info + "?sns_token=#{@sns_token['sns_token']}").parsed end