# Path: pytube/request.py
# def _execute_request(
#     url,
#     method=None,
#     headers=None,
#     data=None,
#     timeout=socket._GLOBAL_DEFAULT_TIMEOUT
# ):
# def get(url, extra_headers=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
# def post(url, extra_headers=None, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
# def seq_stream(
#     url,
#     timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
#     max_retries=0
# ):
# def stream(
#     url,
#     timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
#     max_retries=0
# ):
# def filesize(url):
# def seq_filesize(url):
# def head(url):


import json
import os
import pathlib
import time
from urllib import parse
from pytube import request
        data = {
            'access_token': self.access_token,
            'refresh_token': self.refresh_token,
            'expires': self.expires
        }
        if not os.path.exists(_cache_dir):
            os.mkdir(_cache_dir)
        with open(_token_file, 'w') as f:
            json.dump(data, f)

    def refresh_bearer_token(self, force=False):
        """Refreshes the OAuth token if necessary.

        :param bool force:
            Force-refresh the bearer token.
        """
        if not self.use_oauth:
            return
        # Skip refresh if it's not necessary and not forced
        if self.expires > time.time() and not force:
            return

        # Subtracting 30 seconds is arbitrary to avoid potential time discrepencies
        start_time = int(time.time() - 30)
        data = {
            'client_id': _client_id,
            'client_secret': _client_secret,
            'grant_type': 'refresh_token',
            'refresh_token': self.refresh_token
        }

# Path: pytube/request.py
# def _execute_request(
#     url,
#     method=None,
#     headers=None,
#     data=None,
#     timeout=socket._GLOBAL_DEFAULT_TIMEOUT
# ):
# def get(url, extra_headers=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
# def post(url, extra_headers=None, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
# def seq_stream(
#     url,
#     timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
#     max_retries=0
# ):
# def stream(
#     url,
#     timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
#     max_retries=0
# ):
# def filesize(url):
# def seq_filesize(url):
# def head(url):


# Path: pytube/innertube.py
import json
import os
import pathlib
import time
from urllib import parse
from pytube import request

        data = {
            'access_token': self.access_token,
            'refresh_token': self.refresh_token,
            'expires': self.expires
        }
        if not os.path.exists(_cache_dir):
            os.mkdir(_cache_dir)
        with open(_token_file, 'w') as f:
            json.dump(data, f)

    def refresh_bearer_token(self, force=False):
        """Refreshes the OAuth token if necessary.

        :param bool force:
            Force-refresh the bearer token.
        """
        if not self.use_oauth:
            return
        # Skip refresh if it's not necessary and not forced
        if self.expires > time.time() and not force:
            return

        # Subtracting 30 seconds is arbitrary to avoid potential time discrepencies
        start_time = int(time.time() - 30)
        data = {
            'client_id': _client_id,
            'client_secret': _client_secret,
            'grant_type': 'refresh_token',
            'refresh_token': self.refresh_token
        }

        response = request._execute_request(