module YtConfig
Constants
- ACCOUNT_KEY
- API_BASE
- DEVICE_CODE_URL
- OAUTH_CLIENT_KEY
- OAUTH_PENDING_KEY
- PLUGIN_NAME
- SCOPE
- TOKEN_URL
Public Instance Methods
Source
# File lib/yt_config.rb, line 31 def configured?(client_id: nil, client_secret: nil) creds = credentials(client_id: client_id, client_secret: client_secret) !creds[:client_id].empty? && !creds[:client_secret].empty? end
Source
# File lib/yt_config.rb, line 18 def credentials(client_id: nil, client_secret: nil) resolved_id = client_id.to_s.strip resolved_secret = client_secret.to_s.strip resolved_id = ENV.fetch("YOUTUBE_OAUTH_CLIENT_ID", "").to_s.strip if resolved_id.empty? resolved_secret = ENV.fetch("YOUTUBE_OAUTH_CLIENT_SECRET", "").to_s.strip if resolved_secret.empty? if resolved_id.empty? || resolved_secret.empty? db = load_db_credentials resolved_id = db[:client_id].to_s if resolved_id.empty? resolved_secret = db[:client_secret].to_s if resolved_secret.empty? end { client_id: resolved_id, client_secret: resolved_secret } end
Source
# File lib/yt_config.rb, line 36 def load_db_credentials RabbotDb.get_plugin_json(plugin: PLUGIN_NAME, key: OAUTH_CLIENT_KEY, default: {}) .transform_keys(&:to_sym) rescue StandardError { client_id: "", client_secret: "" } end
Source
# File lib/yt_config.rb, line 43 def setup_hint "YouTube OAuth required — create a Google Cloud project, enable YouTube Data API v3, " \ "create OAuth desktop credentials, then set YOUTUBE_OAUTH_CLIENT_ID and " \ "YOUTUBE_OAUTH_CLIENT_SECRET (or store via RabbotDb plugin_data)." end
Source
# File lib/yt_config.rb, line 49 def signup_steps [ "Create a Gmail account in your browser (CAPTCHA/phone required — cannot be automated).", "Open YouTube and create a channel for that Google account.", "In Google Cloud Console: enable YouTube Data API v3 and create OAuth client credentials.", "Set YOUTUBE_OAUTH_CLIENT_ID and YOUTUBE_OAUTH_CLIENT_SECRET on the bot host.", "PM the bot: !yt auth — visit the URL and enter the code to link this bot persona." ] end