Module: Tiktok::Open::Sdk

Defined in:
lib/tiktok/open/sdk.rb,
lib/tiktok/open/sdk/config.rb,
lib/tiktok/open/sdk/version.rb,
lib/tiktok/open/sdk/http_client.rb,
lib/tiktok/open/sdk/open_api/user.rb,
lib/tiktok/open/sdk/open_api/auth/user.rb,
lib/tiktok/open/sdk/helpers/auth_helper.rb,
lib/tiktok/open/sdk/open_api/auth/client.rb,
lib/tiktok/open/sdk/open_api/post/publish.rb,
lib/tiktok/open/sdk/helpers/response_helper.rb,
lib/tiktok/open/sdk/helpers/string_utils_helper.rb,
lib/tiktok/open/sdk/helpers/validators/token_validator.rb

Overview

Main SDK module providing configuration and error handling

Defined Under Namespace

Modules: Helpers, HttpClient, OpenApi Classes: Config, Error, RequestValidationError

Constant Summary collapse

VERSION =
'0.4.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configConfig?

SDK configuration object

Returns:



31
32
33
# File 'lib/tiktok/open/sdk.rb', line 31

def config
  @config
end

Class Method Details

.client_authOpenApi::Auth::Client

Convenience accessor for client authentication functionality

Examples:

Tiktok::Open::Sdk.client_auth.fetch_client_token

Returns:



77
78
79
# File 'lib/tiktok/open/sdk.rb', line 77

def client_auth
  OpenApi::Auth::Client
end

.configure {|config| ... } ⇒ Config

Configures the TikTok Open SDK.

This method yields the configuration object, allowing you to set client credentials and other options.

Examples:

Tiktok::Open::Sdk.configure do |config|
  config.client_key = 'your_key'
  config.client_secret = 'your_secret'
  config.user_auth.auth_url = 'https://www.tiktok.com/v2/auth/authorize/'
  config.user_auth.token_url = 'https://open.tiktokapis.com/v2/oauth/token/'
  config.user_auth.scopes = %w[user.info.basic video.list]
  config.user_auth.redirect_uri = 'https://your-redirect-uri.example.com'
  config.load_omniauth = true
end

Yield Parameters:

  • config (Config)

    the configuration object

Returns:

  • (Config)

    the configured object



51
52
53
54
55
56
57
58
59
# File 'lib/tiktok/open/sdk.rb', line 51

def configure
  self.config ||= Config.new

  yield(config)

  load_omniauth! if config.load_omniauth

  config
end

.postOpenApi::Post::Publish

Convenience accessor for post publish functionality

Examples:

Tiktok::Open::Sdk.post.video_init(access_token: 'token', post_info: , source_info: source_info)

Returns:



87
88
89
# File 'lib/tiktok/open/sdk.rb', line 87

def post
  OpenApi::Post::Publish
end

.userOpenApi::User

Convenience accessor for user functionality

Examples:

Tiktok::Open::Sdk.user.info(access_token: 'token')

Returns:



97
98
99
# File 'lib/tiktok/open/sdk.rb', line 97

def user
  OpenApi::User
end

.user_authOpenApi::Auth::User

Convenience accessor for user authentication functionality

Examples:

Tiktok::Open::Sdk.user_auth.authorization_uri

Returns:



67
68
69
# File 'lib/tiktok/open/sdk.rb', line 67

def user_auth
  OpenApi::Auth::User
end