LyricsGenius
LyricsGenius copied to clipboard
Fix initiating OAuth2 InvalidTokenError
Since OAuth
2 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.