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

"Invalid client_id" #48

Open
bramnet opened this issue Sep 2, 2021 · 2 comments
Open

"Invalid client_id" #48

bramnet opened this issue Sep 2, 2021 · 2 comments

Comments

@bramnet
Copy link

bramnet commented Sep 2, 2021

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

@Pedrorait
Copy link

Pedrorait commented Sep 9, 2021

same here, is there a way to avoid it?

@whoisoscar
Copy link

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)

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

3 participants