if "None" in None:
# Call get_auth_header() function with the "access_token" from the token_response.
headers = None(
access_token=None["None"]
)
print("Token has been refreshed")
continue # Retry the request with the updated token
else:
print("Failed to refresh token.")
return []
I’m not understanding the “None” in “” and also the headers part, can someone please give me a tip?
Hello @Ricardo_Lousada,
This is the same step as before but this time your are refreshing your auth_header if you get a 401 error. The 401 error means that your access_token has expired after 60minutes:
if the access_token in the token_response you get in the previous line, then continue:
Call the get_auth_header() function with the access_token[“access_token”] from the token_response.
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[42], line 1 ----> 1 responses = paginated_new_releases(endpoint_request=get_new_releases, 2 url=URL_NEW_RELEASES, 3 access_token=token.get(‘access_token’), 4 offset=0, limit=20) Cell In[41], line 32, in paginated_new_releases(endpoint_request, url, access_token, offset, limit) 29 response = endpoint_request(**kwargs) 30 # Use extend() method to add the albums’ items to the list of responses. 31 # responses.None(response.None(‘None’).None(‘None’)) —> 32 responses.extend(response.albums(‘None’).items(‘None’)) 33 # .items(‘None’)) 34 # Get the total number of the elements in albums and save it in the variable total_elements. 35 total_elements = responses.albums(‘None’).total(‘None’)
Your code contains a lot of “None"s. You are supposed to follow the instructions to replace these with the correct values and run the code cell afterwards.
My assignment says “Deadline Pass this assignment by Sep 11, 1:59 AM CDT”, what this deadlight means. If I don’t complete the assignment by 11th I will fail the course, I need to restart the course from the scratch or I need to redo whole week material again …
execution if going into infinite loop, always pulling first 20 elements with offset = 0 and limit =20, offset value is not increasing in the loop. Any hint why it is going to infinite loop
if “access_token” in token_response:
headers = get_auth_header(
access_token=token_response[“access_token”]
)
print(“Token has been refreshed”)
continue
else:
print(“Failed to refresh token.”)
return
if "access_token" in token_response:
This checks if the dictionary token_response contains the key "access_token".
If it does, that means the token refresh worked and you got a new token.