Class: OmniAuth::Strategies::TiktokOauth2
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::TiktokOauth2
- Defined in:
- lib/omniauth/strategies/tiktok_oauth2.rb
Constant Summary collapse
- USER_INFO_URL =
'https://business-api.tiktok.com/open_api/v1.3/user/info/'
Instance Method Summary collapse
- #authorize_params ⇒ Object
- #build_access_token ⇒ Object
-
#callback_url ⇒ Object
Remove params as callback URL must match exactly the URL defined for the application.
- #headers ⇒ Object
- #raw_info ⇒ Object
- #token_params ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
20 21 22 23 24 |
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 20 def super.tap do |params| params[:app_id] = .client_id end end |
#build_access_token ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 67 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(.auth_token_params) ) end |
#callback_url ⇒ Object
Remove params as callback URL must match exactly the URL defined for the application
44 45 46 |
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 44 def callback_url super.split('?').first end |
#headers ⇒ Object
61 62 63 64 65 |
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 61 def headers { 'Access-Token' => access_token.token, } end |
#raw_info ⇒ Object
57 58 59 |
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 57 def raw_info @raw_info ||= access_token.get(USER_INFO_URL, headers: headers, parse: :tiktok).parsed end |
#token_params ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/omniauth/strategies/tiktok_oauth2.rb', line 48 def token_params .token_params.merge( app_id: .client_id, secret: .client_secret, auth_code: request.params["auth_code"], parse: :tiktok, ) end |