File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ def search(query, page):
8888
8989 if data is None :
9090 access_token = get_access_token ()
91+ url = f"{ base_url } /multiquery"
9192 headers = {
9293 "Client-ID" : settings .IGDB_ID ,
9394 "Authorization" : f"Bearer { access_token } " ,
@@ -120,13 +121,23 @@ def search(query, page):
120121 response = services .api_request (
121122 Sources .IGDB .value ,
122123 "POST" ,
123- f" { base_url } /multiquery" ,
124+ url ,
124125 data = multiquery ,
125126 headers = headers ,
126127 )
127128
128129 except requests .exceptions .HTTPError as error :
129- handle_error (error )
130+ error_resp = handle_error (error )
131+ if error_resp and error_resp .get ("retry" ):
132+ # Retry the request with the new access token
133+ headers ["Authorization" ] = f"Bearer { get_access_token ()} "
134+ response = services .api_request (
135+ Sources .IGDB .value ,
136+ "POST" ,
137+ url ,
138+ data = data ,
139+ headers = headers ,
140+ )
130141
131142 search_results = next (
132143 (item ["result" ] for item in response if item ["name" ] == "SearchResults" ),
You can’t perform that action at this time.
0 commit comments