Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to TikTok API v1.3 #10

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should lock this from version 3 as well? I guess omni-oauth2 already has that upper guard though.

Copy link
Collaborator Author

@stenlarsson stenlarsson Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we only indirectly depend on oauth2, so it is up to omni-oauth2 to restrict it properly. No need to restrict it more than necessary here.

end