Class: OmniAuth::Strategies::Douyin

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

Defined Under Namespace

Classes: NoAuthorizationCodeError

Constant Summary collapse

DEFAULT_SCOPE =
'trial.whitelist,user_info'
USER_INFO_URL =
'https://open.douyin.com/oauth/userinfo'

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



60
61
62
63
64
65
66
67
# File 'lib/omniauth/strategies/douyin.rb', line 60

def authorize_params
  super.tap do |params|
    params[:scope] ||= DEFAULT_SCOPE
    params[:response_type] = 'code'
    params.delete(:client_key)
    params[:client_key] = options.client_key
  end
end

#callback_urlObject



56
57
58
# File 'lib/omniauth/strategies/douyin.rb', line 56

def callback_url
  options[:callback_url] || (full_host + script_name + callback_path)
end

#raw_infoObject



50
51
52
53
54
# File 'lib/omniauth/strategies/douyin.rb', line 50

def raw_info
  @raw_info ||= access_token
                .get("#{USER_INFO_URL}?open_id=#{access_token.params['open_id']}&access_token=#{access_token.token}")
                .parsed || {}
end

#token_paramsObject



69
70
71
72
73
74
# File 'lib/omniauth/strategies/douyin.rb', line 69

def token_params
  super.tap do |params|
    params.delete(:client_key)
    params[:client_key] = options.client_key
  end
end