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

Can't create client with a cookie. HTTP 403 response #4

Open
hhauschild opened this issue Apr 20, 2024 · 1 comment
Open

Can't create client with a cookie. HTTP 403 response #4

hhauschild opened this issue Apr 20, 2024 · 1 comment

Comments

@hhauschild
Copy link

The line command suno.Suno(cookie=suno_cookie) always returns the following exception for me:

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Cell In[16], [line 2](vscode-notebook-cell:?execution_count=16&line=2)
      [1](vscode-notebook-cell:?execution_count=16&line=1) # Create a client
----> [2](vscode-notebook-cell:?execution_count=16&line=2) client = suno.Suno(cookie=suno_cookie)
      [3](vscode-notebook-cell:?execution_count=16&line=3) credits = client.get_credits()
      [4](vscode-notebook-cell:?execution_count=16&line=4) print(f"credits before song generation: {credits} ")

File [c:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\suno\suno.py:78](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:78), in Suno.__init__(self, cookie)
     [76](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:76)     raise Exception("environment variable SUNO_COOKIE is not set")
     [77](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:77) super().__init__(cookie)
---> [78](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:78) self._sid = self._get_sid()
     [79](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:79) self.songs = Songs(self)

File [c:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\suno\suno.py:85](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:85), in Suno._get_sid(self)
     [83](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:83) response = super().request("GET", url)
     [84](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:84) if not response.ok:
---> [85](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:85)     raise Exception(f"failed to get SID: {response.status_code}")
     [86](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:86) data = response.json()
     [87](file:///C:/Users/***/AppData/Local/Programs/Python/Python312/Lib/site-packages/suno/suno.py:87) return data.get("response").get("last_active_session_id")

Exception: failed to get SID: 403

I got my cookie from the Request "https://clerk.suno.com/v1/client?_clerk_js_version=4.72.0-snapshot.vc141245" out of the Chrome browser, which seems to be what the screenshot in the quickstart documentation suggests. I have tried Cookies from other requests too and made sure that they were not older that a minute or so.
I have updated suno-api to version 0.1.2, but that did not fix the problem.

The problematic request seems to be a GET "https://clerk.suno.ai/v1/client?_clerk_js_version=4.70.5". When I open this URL in the browser, it is blocked by Cloudflare ("The action you just performed triggered the security solution. "). When I open https://clerk.suno.com/v1/client?_clerk_js_version=4.72.0-snapshot.vc141245 instead, I get a valid response. So the version-id in the URL seems to be the problem. Not sure if this is only a temporary issue, but it persists for some days now.

@hhauschild
Copy link
Author

To correct myself: the problem was not the version string, but the host name clerk.suno.ai instead of clerk.suno.com.

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

1 participant