Strategy to authenticate with TikTok (Marketing API) via OAuth2 in OmniAuth
Sign up and create your Application at https://ads.tiktok.com/i18n/login. Note the App ID and the App Secret.
For more details, read the docs: https://ads.tiktok.com/marketing_api/docs?rid=1dmrkuztuhi&id=100510
Add to your Gemfile
:
gem 'omniauth-tiktok-oauth2'
Then bundle install
.
Here's an example for adding the middleware to a Rails app in config/initializers/omniauth.rb
:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :tiktok_oauth2, ENV['TIKTOK_APP_ID'], ENV['TIKTOK_SECRET']
end
You can now access the OmniAuth TikTok OAuth2 URL: /auth/tiktok_oauth2
name
: The name of the strategy. The default name istiktok_oauth2
but it can be changed to any value, for exampletiktok
. The OmniAuth URL will thus change to/auth/tiktok
and theprovider
key in the auth hash will then returntiktok
.