PyImgur icon indicating copy to clipboard operation
PyImgur copied to clipboard

"Invalid client_id"

Open bramnet opened this issue 3 years ago • 2 comments

Potentially I'm just being dumb, but I'm running into this weird situation where the PyImgur is able to upload 2 or so images and then it starts complaining that I have the wrong client ID. I tried slowing it down thinking I was hitting Imgur's API limit, but even at 10 second delays, it still pops up. I don't see any warning from Imgur that my client ID is bad, so I'm not sure what's going on...

Traceback (most recent call last): File "", line 76, in main() File "", line 70, in main link = ImgurBatch(files) File "", line 57, in ImgurBatch links.append(imgurupload(item)) File "", line 24, in imgurupload uploaded_image = im.upload_image(PATH, title="") File "C:\Users\Bram\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyimgur_init_.py", line 1150, in upload_image resp = self._send_request(self.base_url + "/3/image", File "C:\Users\Bram\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyimgur_init.py", line 731, in _send_request result = request.send_request(url, verify=self.verify, **kwargs) File "C:\Users\Bram\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyimgur\request.py", line 102, in send_request resp.raise_for_status() File "C:\Users\Bram\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Permission Denied for url: https://api.imgur.com/3/image

bramnet avatar Sep 02 '21 22:09 bramnet

same here, is there a way to avoid it?

Pedrorait avatar Sep 09 '21 22:09 Pedrorait

I was experiencing the same issue and messed around with my code to make it work. This may or may not work for you but hope it helps.

So the way my code worked is it used a loop to upload a series of images it created. The issue seemed to be that I declared my client ID within the loop, thus creating parallel sessions with the same client ID, which I suppose set off some flag on imgur's end.

Therefore, make sure you're not authenticating your client ID every time you upload an image as it's not necesary. Check out my fixed code below:

im = pyimgur.Imgur("XXX")

for i in range(10):

    uploaded_image = im.upload_image("current_qr.png")
    link_to_image = (uploaded_image.link)

whoisoscar avatar Sep 10 '21 10:09 whoisoscar