Class: OmniAuth::Strategies::TiktokOauth2

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

Constant Summary collapse

USER_INFO_URL =
'https://business-api.tiktok.com/open_api/v1.2/user/info/'

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



20
21
22
23
24
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 20

def authorize_params
  super.tap do |params|
    params[:app_id] = options.client_id
  end
end

#callback_urlObject

Remove params as callback URL must match exactly the URL defined for the application



44
45
46
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 44

def callback_url
  super.split('?').first
end

#headersObject



61
62
63
64
65
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 61

def headers
  {
    'Access-Token' => access_token.token,
  }
end

#raw_infoObject



57
58
59
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 57

def raw_info
  @raw_info ||= access_token.get(USER_INFO_URL, headers: headers, parse: :tiktok).parsed
end

#token_paramsObject



48
49
50
51
52
53
54
55
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 48

def token_params
  options.token_params.merge(
    app_id: options.client_id,
    secret: options.client_secret,
    auth_code: request.params["code"],
    parse: :tiktok,
  )
end