Class: Tiktok::Open::Omniauth::Strategies::TiktokOpenSdk
- Inherits:
-
OmniAuth::Strategies::OAuth2
- Object
- OmniAuth::Strategies::OAuth2
- Tiktok::Open::Omniauth::Strategies::TiktokOpenSdk
- Defined in:
- lib/tiktok/open/omniauth/strategies/tiktok_open_sdk.rb
Overview
OmniAuth strategy for TikTok Open Platform.
Integrates TikTok OAuth2 authentication with OmniAuth.
Supported scopes and their user info fields:
- user.info.basic: open_id, union_id, display_name, avatar_url, avatar_url_100, avatar_large_url
- user.info.profile: profile_deep_link, bio_description, is_verified, username
- user.info.stats: follower_count, following_count, likes_count, video_count
Defined Under Namespace
Classes: AccessToken
Instance Method Summary collapse
-
#authorize_params ⇒ Hash
Builds the authorization parameters for the OAuth2 request, adding the TikTok client_key.
-
#build_access_token ⇒ AccessToken
Builds the access token from TikTok's token endpoint.
-
#callback_url ⇒ String
Returns the callback URL without query parameters.
-
#request_phase ⇒ Object
Handles the initial OAuth2 request phase.
Instance Method Details
#authorize_params ⇒ Hash
Builds the authorization parameters for the OAuth2 request, adding the TikTok client_key.
110 111 112 113 114 |
# File 'lib/tiktok/open/omniauth/strategies/tiktok_open_sdk.rb', line 110 def super.tap do |params| params[:client_key] = .client_id end end |
#build_access_token ⇒ AccessToken
Builds the access token from TikTok's token endpoint.
87 88 89 90 91 |
# File 'lib/tiktok/open/omniauth/strategies/tiktok_open_sdk.rb', line 87 def build_access_token response = fetch_access_token validate_token_response(response) create_access_token(response[:response]) end |
#callback_url ⇒ String
Returns the callback URL without query parameters.
79 80 81 |
# File 'lib/tiktok/open/omniauth/strategies/tiktok_open_sdk.rb', line 79 def callback_url super.split('?').first end |
#request_phase ⇒ Object
Handles the initial OAuth2 request phase.
96 97 98 99 100 101 102 103 104 |
# File 'lib/tiktok/open/omniauth/strategies/tiktok_open_sdk.rb', line 96 def request_phase params = .merge('response_type' => 'code') if params.key?(:client_secret) || params.key?('client_secret') raise ArgumentError, 'client_secret is not allowed in authorize URL query params' end redirect client.(params) end |