diff --git a/lib/omniauth/strategies/tiktok_oauth2.rb b/lib/omniauth/strategies/tiktok_oauth2.rb index 4d2ab3e..ba81d12 100644 --- a/lib/omniauth/strategies/tiktok_oauth2.rb +++ b/lib/omniauth/strategies/tiktok_oauth2.rb @@ -8,12 +8,12 @@ module OmniAuth module Strategies class TiktokOauth2 < OmniAuth::Strategies::OAuth2 - USER_INFO_URL = 'https://business-api.tiktok.com/open_api/v1.2/user/info/' + USER_INFO_URL = 'https://business-api.tiktok.com/open_api/v1.3/user/info/' option :name, "tiktok_oauth2" option :client_options, site: 'https://business-api.tiktok.com/', authorize_url: 'https://ads.tiktok.com/marketing_api/auth/', - token_url: 'https://business-api.tiktok.com/open_api/v1.2/oauth2/access_token/' + token_url: 'https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/' option :pkce, true @@ -63,6 +63,17 @@ def headers 'Access-Token' => access_token.token, } end + + def build_access_token + client.auth_code.get_token( + request.params['code'], + { + redirect_uri: callback_url, + headers: {'Content-Type' => 'application/json'}, + }.merge(token_params.to_hash(symbolize_keys: true)), + deep_symbolize(options.auth_token_params) + ) + end end end end diff --git a/omniauth-tiktok-oauth2.gemspec b/omniauth-tiktok-oauth2.gemspec index f14ad14..326f086 100644 --- a/omniauth-tiktok-oauth2.gemspec +++ b/omniauth-tiktok-oauth2.gemspec @@ -12,6 +12,6 @@ Gem::Specification.new do |gem| gem.files = `git ls-files`.split("\n") gem.require_paths = ['lib'] - gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.6' - gem.add_runtime_dependency 'oauth2', '~> 1.1' + gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.8' + gem.add_runtime_dependency 'oauth2', '>= 2.0.7' end