Class: OmniAuth::Dingtalk::Client::EnterpriseInternal

Inherits:
Base
  • Object
show all
Defined in:
lib/omniauth-dingtalk/client/enterprise_internal.rb

Constant Summary collapse

TOKEN_URL =
'/gettoken'

Constants inherited from Base

Base::AUTHORIZE_URL, Base::GET_USER_ID_BY_UNIONID_URL, Base::GET_USER_INFO_BY_CODE_URL, Base::GET_USER_INFO_BY_ID_URL

Instance Method Summary collapse

Methods inherited from Base

#get_token, #get_user_id_by_unionid, #get_user_info_by_code, #get_user_info_by_id, #initialize, #token_url

Constructor Details

This class inherits a constructor from OmniAuth::Dingtalk::Client::Base

Instance Method Details

#get_user_info(params = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/omniauth-dingtalk/client/enterprise_internal.rb', line 15

def (params = {})
  resp = (params[:code])
   = resp['user_info'] || {}
  return  if ['unionid'].to_s.empty?

  user_id = get_user_id_by_unionid(params[:access_token], ['unionid']).dig('result', 'userid')
  return  if user_id.to_s.empty?

  result = (params[:access_token], user_id)['result']
  .merge(result || {})
end

#token_paramsObject



11
12
13
# File 'lib/omniauth-dingtalk/client/enterprise_internal.rb', line 11

def token_params
  { appkey: id, appsecret: secret }
end