yt-dlp/yt-dlp · error · ExtractorError

Unable to get temporary token

Error message

Unable to get temporary token

What it means

Error "Unable to get temporary token" thrown in yt-dlp/yt-dlp.

Source

Thrown at yt_dlp/extractor/redgifs.py:71

            'extractor': 'RedGifs',
            'title': ' '.join(gif_data.get('tags') or []) or 'RedGifs',
            'timestamp': int_or_none(gif_data.get('createDate')),
            'uploader': gif_data.get('userName'),
            'duration': int_or_none(gif_data.get('duration')),
            'view_count': int_or_none(gif_data.get('views')),
            'like_count': int_or_none(gif_data.get('likes')),
            'categories': gif_data.get('tags') or [],
            'tags': gif_data.get('tags'),
            'age_limit': 18,
            'formats': formats,
        }

    def _fetch_oauth_token(self, video_id):
        # https://github.com/Redgifs/api/wiki/Temporary-tokens
        auth = self._download_json('https://api.redgifs.com/v2/auth/temporary',
                                   video_id, note='Fetching temporary token')
        if not auth.get('token'):
            raise ExtractorError('Unable to get temporary token')
        self._API_HEADERS['authorization'] = f'Bearer {auth["token"]}'

    def _call_api(self, ep, video_id, **kwargs):
        for first_attempt in True, False:
            if 'authorization' not in self._API_HEADERS:
                self._fetch_oauth_token(video_id)
            try:
                headers = dict(self._API_HEADERS)
                headers['x-customheader'] = f'https://www.redgifs.com/watch/{video_id}'
                data = self._download_json(
                    f'https://api.redgifs.com/v2/{ep}', video_id, headers=headers, **kwargs)
                break
            except ExtractorError as e:
                if first_attempt and isinstance(e.cause, HTTPError) and e.cause.status == 401:
                    del self._API_HEADERS['authorization']  # refresh the token
                    continue
                raise

View on GitHub (pinned to 81ecd58b13)

Solutions

  1. Retry; the temporary token request failed
  2. Update yt-dlp in case the API changed

When it happens

Trigger: Thrown at yt_dlp/extractor/redgifs.py:71 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of yt-dlp/yt-dlp@81ecd58b13 (2026-08-22). Data as JSON: /api/errors/2890d7727a15da56. Report an issue: GitHub.