Skip to content

Commit

Permalink
Merge pull request #10 from burtcorp/migrate-to-api-v1.3
Browse files Browse the repository at this point in the history
Migrate to TikTok API v1.3
  • Loading branch information
stenlarsson authored Jan 12, 2023
2 parents a53e099 + e5563e4 commit c6389ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions lib/omniauth/strategies/tiktok_oauth2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions omniauth-tiktok-oauth2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c6389ab

Please sign in to comment.