Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Total error [Errno 403] 403 Client Error: Forbidden for url #267

Open
Glour opened this issue Feb 1, 2024 · 3 comments
Open

Total error [Errno 403] 403 Client Error: Forbidden for url #267

Glour opened this issue Feb 1, 2024 · 3 comments

Comments

@Glour
Copy link

Glour commented Feb 1, 2024

Describe the bug
I get an error every time I make an API request to get a chart

Expected behavior
I get error: "Total error [Errno 403] 403 Client Error: Forbidden for url". My API requests are blocked, access is denied and I cannot bypass this block. When I click on the link in the response, I get to the page with protection from cloud flare

To Reproduce

genius = lyricsgenius.Genius(access_token='API_KEY',
                             timeout=20,
                             retries=3)

def get_lyrics():
    try:
        while True:
            chart = genius.charts(time_period='all_time', chart_genre='rap', per_page='50', page=page)
            print(chart)

Include the error message associated with the bug.

Total error [Errno 403] 403 Client Error: Forbidden for url: https://genius.com/api/songs/chart?time_period=all_time&chart_genre=rap&per_page=50&page=1&text_format=plain

Version info

  • Package version lyricsgenius 3.0.1
  • OS: linux ubuntu 22.04

Additional context
Please help me solve this problem

@Lionheartxx
Copy link

I have the same error!
link packages lyricgenius authenticate: https://lyricsgenius.readthedocs.io/en/master/reference/auth.html#oauth2
Auth
OAuth2
You can use this class to authenticate yourself or get URLs to redirect your users to and get them to give your Genius app the premissions you need. To find out more about how to use this class visit the Snippets.

classlyricsgenius.auth.OAuth2(client_id, redirect_uri, client_secret=None, scope=None, state=None, client_only_app=False)
Genius OAuth2 authorization flow.

Using this class you can authenticate a user, and get their token.

Parameters
client_id (str) – Client ID

redirect_uri (str) – Whitelisted redirect URI.

client_secret (str, optional) – Client secret.

scope (tuple | "all", optional) – Token privileges.

state (str, optional) – Request state.

client_only_app (bool, optional) – True to use the client-only authorization flow, otherwise False.

Raises
AssertionError – If neither client_secret, nor client_only_app is supplied.
image

@eoli3n
Copy link

eoli3n commented Apr 25, 2024

Same here, did you manage to workaround this ?

root@sopel:/data-test # ./test-env/bin/python3
Python 3.9.18 (main, Apr  9 2024, 01:10:56) 
[Clang 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1 on freebsd14
Type "help", "copyright", "credits" or "license" for more information.
>>> import lyricsgenius
>>> genius.search_lyrics(text)
KeyboardInterrupt
>>> genius = lyricsgenius.Genius('*********************************************')
>>> genius.search_lyrics('salut')
Traceback (most recent call last):
  File "/data-test/test-env/lib/python3.9/site-packages/lyricsgenius/api/base.py", line 80, in _make_request
    response.raise_for_status()
  File "/data-test/test-env/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://genius.com/api/search/lyric?q=salut

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data-test/test-env/lib/python3.9/site-packages/lyricsgenius/api/public_methods/search.py", line 125, in search_lyrics
    return self.search(search_term, per_page, page, endpoint)
  File "/data-test/test-env/lib/python3.9/site-packages/lyricsgenius/api/public_methods/search.py", line 45, in search
    return self._make_request(path, params_=params, public_api=True)
  File "/data-test/test-env/lib/python3.9/site-packages/lyricsgenius/api/base.py", line 88, in _make_request
    raise HTTPError(response.status_code, error)
requests.exceptions.HTTPError: [Errno 403] 403 Client Error: Forbidden for url: https://genius.com/api/search/lyric?q=salut

@allerter
Copy link
Collaborator

This issue has already been discussed extensively and the only solution is explained in another issue of the same origin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants