Ошибка 403 imgur

I’ve been making a react app and recently whenever I try to access images from imgur like so

this.setState({
  imgUrl: `https://i.imgur.com/${this.props.image.id}b.png`,
  imgBigUrl: `https://i.imgur.com/${this.props.image.id}l.png`
});

And it’s being rendered like this

<img src={this.state.imgUrl}/>

But I keep getting 403 forbidden, but when I use postman or visit it in the browser it’s fine. I’m also accessing the API by passing in an album url like

https://imgur.com/gallery/zrUFj

and getting all the images from there to be displayed in the app (where i get 403 errors)

I’m unsure where I could be have done something wrong, I’ve also tried getting a new client ID for the API authorization, still hasn’t worked. Anyone have any suggestions?

asked May 10, 2017 at 14:28

Justin Mercado's user avatar

Imgur’s CDN seems to restrict access to images from a 127.0.0.1 referer. This has been reported to them as an issue (matter of server configuration).

Meanwhile try to change your dev server host from 127.0.0.1 to localhost or maybe your real IP address.

xpt's user avatar

xpt

20.5k37 gold badges127 silver badges216 bronze badges

answered May 11, 2017 at 8:33

Sewer Orłow's user avatar

Sewer OrłowSewer Orłow

2462 silver badges2 bronze badges

5

Note that a quick and hacky way to fix this is to simply remove the referrer header either via a <meta> tag:

<!DOCTYPE html>
<html>
<head>
  <meta name="referrer" content="no-referrer">
</head>
<body>
  ...
</body>
</html>

or in your fetch:

await fetch("https://i.imgur.com/iie9XhM.jpg", {referrer:""})

or (as mentioned by @Theblockbuster1) in the img tag:

<img src="https://i.imgur.com/iie9XhM.jpg" referrerpolicy="no-referrer">

answered Apr 26, 2021 at 16:07

joe's user avatar

joejoe

3,8141 gold badge32 silver badges41 bronze badges

1

Every other image I see hotlinked from Imgur returns a «403 — Forbidden» error.

If I copy and paste the link into my browser the image will load. Or if I delete the initial i. in the URL, the image loads.

The image will not load if it’s used in a BBCode style tag, or if I right click on it and choose open in a new tab.

Do you know the cause or a fix?

These are a couple of examples that you’ll probably be able to see, but I can’t unless I do one of those above mentioned actions:

View post on imgur.com

View post on imgur.com

pnuts's user avatar

pnuts

17.3k5 gold badges51 silver badges103 bronze badges

asked Apr 13, 2012 at 23:02

Louis Waweru's user avatar

Louis WaweruLouis Waweru

1,6145 gold badges22 silver badges41 bronze badges

2

I found out that imgur has an outright ban on the site for some reason. No one knows why.

The workaround is to use the site’s https connection, then the images will load. We guess imgur didn’t ban https://site.com.

answered May 16, 2012 at 0:59

Louis Waweru's user avatar

Louis WaweruLouis Waweru

1,6145 gold badges22 silver badges41 bronze badges

1

I’m in the same boat with Greenshot’s Imgur Plugin. Greenshot is awesome.

According to Imgur Documentation

Status Code: 403

Forbidden. You don’t have access to this action. If you’re getting this error, check that you haven’t run out of API credits or make sure you’re sending the OAuth headers correctly and have valid tokens/secrets.

I assume in my case that many other people love Greenshot and the application just ran out of API credits or something? In your case it sounds like a broken authentication token though I’m knowledge about enough to know how to hypothetically even approach fixing it.

Edit:

ShareX a similar screen shot program seems to have run into a similar problem at some point and the problem on their end was users had to reauthenticate. I’m going to try it on my end and if that works that it might be linked to the problem of hotlink 403 errors.

I wasn’t able to relogin to Imgur but fiddling with the configuration settings (or waiting just 20 more minutes while I tried to figure out how to logout) seems to have fixed the issue.

Community's user avatar

answered May 24, 2016 at 0:00

Wolfkin's user avatar

Possibly imgur does not allow hotlinking, although I couldn’t find any mention about that in their Terms Of Service.
If it does however ban hotlinking, you wouldn’t be able to see picture in another website.
Some services (e.g. Blogger) also did similar thing in the past.

answered May 15, 2012 at 22:17

Tschareck's user avatar

TschareckTschareck

1,6041 gold badge15 silver badges33 bronze badges

2

I’ve been making a react app and recently whenever I try to access images from imgur like so

this.setState({
  imgUrl: `https://i.imgur.com/${this.props.image.id}b.png`,
  imgBigUrl: `https://i.imgur.com/${this.props.image.id}l.png`
});

And it’s being rendered like this

<img src={this.state.imgUrl}/>

But I keep getting 403 forbidden, but when I use postman or visit it in the browser it’s fine. I’m also accessing the API by passing in an album url like

https://imgur.com/gallery/zrUFj

and getting all the images from there to be displayed in the app (where i get 403 errors)

I’m unsure where I could be have done something wrong, I’ve also tried getting a new client ID for the API authorization, still hasn’t worked. Anyone have any suggestions?

asked May 10, 2017 at 14:28

Justin Mercado's user avatar

Imgur’s CDN seems to restrict access to images from a 127.0.0.1 referer. This has been reported to them as an issue (matter of server configuration).

Meanwhile try to change your dev server host from 127.0.0.1 to localhost or maybe your real IP address.

xpt's user avatar

xpt

20.5k37 gold badges127 silver badges216 bronze badges

answered May 11, 2017 at 8:33

Sewer Orłow's user avatar

Sewer OrłowSewer Orłow

2462 silver badges2 bronze badges

5

Note that a quick and hacky way to fix this is to simply remove the referrer header either via a <meta> tag:

<!DOCTYPE html>
<html>
<head>
  <meta name="referrer" content="no-referrer">
</head>
<body>
  ...
</body>
</html>

or in your fetch:

await fetch("https://i.imgur.com/iie9XhM.jpg", {referrer:""})

or (as mentioned by @Theblockbuster1) in the img tag:

<img src="https://i.imgur.com/iie9XhM.jpg" referrerpolicy="no-referrer">

answered Apr 26, 2021 at 16:07

joe's user avatar

joejoe

3,8141 gold badge32 silver badges41 bronze badges

1

Have you ever tried to access an Imgur image and received a 403 error code? This error code means that you do not have permission to access the requested resource. In this guide, we will go over some possible causes of this error and provide some code examples to help you troubleshoot the issue.

Possible Causes

1. Invalid API key

If you are using Imgur’s API to access images, you may receive a 403 error if your API key is invalid or has expired.

2. Authentication Required

If you are trying to access a private image, you may need to authenticate yourself first. This can be done by passing your client ID or access token in the headers of your API request.

3. Rate limiting

Imgur has rate limits on their API requests to prevent abuse. If you exceed these limits, you may receive a 403 error.

4. Deleted Image

If the image you are trying to access has been deleted, you may receive a 403 error.

Code Examples

Python

To make an API request to Imgur using Python, you can use the requests library. Here is an example of how to pass your client ID in the headers of your request:

import requests

headers = {
    "Authorization": "Client-ID {client_id}"
}

response = requests.get("https://api.imgur.com/3/image/{image_id}", headers=headers)

if response.status_code == 403:
    print("Access Denied")

JavaScript

To make an API request to Imgur using JavaScript, you can use the fetch function. Here is an example of how to pass your access token in the headers of your request:

const headers = {
    "Authorization": "Bearer {access_token}"
}

fetch("https://api.imgur.com/3/image/{image_id}", { headers })
    .then(response => {
        if (response.status === 403) {
            console.log("Access Denied");
        }
    });

Conclusion

In this guide, we have gone over some possible causes of Imgur images returning 403 errors and provided some code examples to help you troubleshoot the issue. By following these examples and checking for common causes, you should be able to resolve this issue and access the images you need.

Я нахожусь в той же лодке с Greenshot’ Imgur Plugin. Greenshot — это потрясающе.

Согласно документации Imgur

Код состояния: 403

Запрещено. У вас нет доступа к этому действию. Если вы получаете эту ошибку, проверьте, не закончились ли у вас кредиты API, или убедитесь, что вы правильно отправляете заголовки OAuth и имеете действительные токены/секреты.

Я предполагаю, что в моем случае многие другие люди любят Greenshot, и у приложения просто закончились кредиты API или что-то еще? В вашем случае это похоже на сломанный токен аутентификации, хотя я’достаточно осведомлен, чтобы знать, как гипотетически хотя бы приблизиться к его исправлению.

Edit:

ShareX, похожая программа для снимков экрана, похоже, столкнулась с похожей проблемой в какой-то момент, и проблема с их стороны заключалась в том, что пользователи должны были повторно аутентифицироваться. Я собираюсь попробовать это на своей стороне, и если это сработает, то это может быть связано с проблемой 403 ошибки горячей ссылки.

Я не смог заново войти в Imgur, но возня с настройками конфигурации (или ожидание еще 20 минут, пока я пытался понять, как выйти из системы), похоже, решила проблему.

Понравилась статья? Поделить с друзьями:
  • Ошибка 403 iis
  • Ошибка 403 google android
  • Ошибка 403 html шаблон
  • Ошибка 403 google аккаунт
  • Ошибка 4020 куосера