LyricsGenius icon indicating copy to clipboard operation
LyricsGenius copied to clipboard

Fix initiating OAuth2 InvalidTokenError

Open allerter opened this issue 3 years ago β€’ 0 comments

Since OAuth2 inherits Sender and calls its __init__, if the user doesn't have the GENIUS_ACCESS_TOKEN env var present, they'll get an InvalidTokenError. This temporary fix which also worked for PublicAPI will work for now until we refactor the classes and make the sender an attribute instead of inheriting it.

Side note: we should definitely switch to using self.sender, because the current public_api_contstructor doesn't work if user decides to subclass Genius:

public_api_constructor = False if self.__class__.__name__ == 'Genius' else True

The variable's value will be True if for example the user's subclass is called MyGenius. This will result in a missing authorization header and a 401 error for all calls that need an access token.

allerter avatar Feb 16 '21 18:02 allerter