module Api module V1 class YoutubeController < BaseController def authorize team = current_user.manageable_teams.find(params[:team_id]) team.entitlements.assert_can_connect_youtube! state = Youtube::OauthState.for_team(team_id: team.id, user_id: current_user.id) url = Youtube::OauthUrl.build(state: state, redirect_uri: ENV.fetch("YOUTUBE_REDIRECT_URI")) render json: { authorization_url: url } end end end end