scrazzz / redgifs

Simple Python API wrapper for the RedGIFs API
https://redgifs.rtfd.io
MIT License
93 stars 13 forks source link

HTTPException 401 when using api.get_gif() #10

Closed jsimons256 closed 2 years ago

jsimons256 commented 2 years ago

Summary

A couple days ago, the redgifs API started giving a 401 exception when calling api functions.

Reproduction Steps

import redgifs, os
api = redgifs.API()
url = input() # Full url of redgifs video
result = api.get_gif(url.split('/')[-1])
response = api.download(result.urls.hd, os.path.join(path ,dir, name + ".mp4"))
api.close()

Expected Result

Code executes and video is downloaded.

Actual Result

Traceback (most recent call last): File "/path/to/file.py", line 26, in result = api.get_gif(sub.url.split('/')[-1]) File "/path/to/site-packages/redgifs/api.py", line 92, in get_gif json: Dict[str, Any] = self.http.get_gif(id)['gif'] File "/path/to/site-packages/redgifs/http.py", line 123, in get_gif return self.request(r, **params) File "/path/to/site-packages/redgifs/http.py", line 111, in request raise HTTPException(r, js) redgifs.errors.HTTPException: 401 (Error: {'code': 'MissingAuthorizationHeader', 'description': 'authorization required to access this service', 'docs': 'https://github.com/Redgifs/api/wiki/API-access'})

System Information

Checklist

Additional Information

The code used to work a couple days ago, but suddenly stopped working.

scrazzz commented 2 years ago

Thanks for opening a bug report.

Yep, this is RedGIFs making breaking changes to their API. Looks like all endpoints now require an API key which you have 0.1% of getting it (see this to know what I'm talking about).

I'm a bit busy right now IRL so I'll see what I can do about this later.

scrazzz commented 2 years ago

Just as a general information for others seeing this: The current version of the library (v1.3.1) is completely broken. No API methods work properly and it returns 401 error.

I need to implement an authentication system in the library so that it works again normally.

scrazzz commented 2 years ago

I've fixed this issue on 1.4.0 (08e42b638bc79ad46b2ef9108fbed003c3ca6a45) with a temporary login method. You can check the example in the README or in the examples folder on how to use it.