{"record":{"id":"2890d7727a15da56","repo":"yt-dlp/yt-dlp","slug":"unable-to-get-temporary-token","errorCode":null,"errorMessage":"Unable to get temporary token","messagePattern":"Unable to get temporary token","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"yt_dlp/extractor/redgifs.py","lineNumber":71,"sourceCode":"            'extractor': 'RedGifs',\n            'title': ' '.join(gif_data.get('tags') or []) or 'RedGifs',\n            'timestamp': int_or_none(gif_data.get('createDate')),\n            'uploader': gif_data.get('userName'),\n            'duration': int_or_none(gif_data.get('duration')),\n            'view_count': int_or_none(gif_data.get('views')),\n            'like_count': int_or_none(gif_data.get('likes')),\n            'categories': gif_data.get('tags') or [],\n            'tags': gif_data.get('tags'),\n            'age_limit': 18,\n            'formats': formats,\n        }\n\n    def _fetch_oauth_token(self, video_id):\n        # https://github.com/Redgifs/api/wiki/Temporary-tokens\n        auth = self._download_json('https://api.redgifs.com/v2/auth/temporary',\n                                   video_id, note='Fetching temporary token')\n        if not auth.get('token'):\n            raise ExtractorError('Unable to get temporary token')\n        self._API_HEADERS['authorization'] = f'Bearer {auth[\"token\"]}'\n\n    def _call_api(self, ep, video_id, **kwargs):\n        for first_attempt in True, False:\n            if 'authorization' not in self._API_HEADERS:\n                self._fetch_oauth_token(video_id)\n            try:\n                headers = dict(self._API_HEADERS)\n                headers['x-customheader'] = f'https://www.redgifs.com/watch/{video_id}'\n                data = self._download_json(\n                    f'https://api.redgifs.com/v2/{ep}', video_id, headers=headers, **kwargs)\n                break\n            except ExtractorError as e:\n                if first_attempt and isinstance(e.cause, HTTPError) and e.cause.status == 401:\n                    del self._API_HEADERS['authorization']  # refresh the token\n                    continue\n                raise\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/yt-dlp/yt-dlp/blob/81ecd58b1394793e6da9998cc19fdb45657f1685/yt_dlp/extractor/redgifs.py#L53-L89","documentation":"Error \"Unable to get temporary token\" thrown in yt-dlp/yt-dlp.","triggerScenarios":"Thrown at yt_dlp/extractor/redgifs.py:71 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry; the temporary token request failed","Update yt-dlp in case the API changed"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"81ecd58b1394793e6da9998cc19fdb45657f1685","analyzedAt":"2026-08-22T12:21:25.439Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}