Imgur

PAID
Verified
By Imgur | Updated 4日前 | Entertainment
Popularity

9.8 / 10

Latency

929ms

Service Level

100%

Health Check

N/A

Back to All Discussions

https://imgur-apiv3.p.mashape.com/3/image 401 (Unauthorized) - has been blocked by CORS policy

Rapid account: Kalashbr
kalashbr
5年前

Hi, i was working good with IMGUR api for upload image for months, but from 2 days ago i’m receiving this message bellow:

OPTIONS
https://imgur-apiv3.p.mashape.com/3/image 401 (Unauthorized)

Access to XMLHttpRequest at ‘https://imgur-apiv3.p.mashape.com/3/image’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Not connected.
Please verify your network connection.

Bellow part of my code for upload photo:

var imgurToken = "";
var clientId = '
’; //private
//var MashapeKey = ‘’; //testing key
var MashapeKey = '
’; //production key

function imgurUpload(token, tel) {
//imgurUpload.show();//imgurUpload.show(); //group.hide();
var auth;
if (token) auth = 'Bearer ’ + token;
else auth = 'Client-ID ’ + clientId;

//auth = 'Client-ID ’ + clientId;
$.ajax({
// url: ‘https://api.imgur.com/3/image’,
url: ‘https://imgur-apiv3.p.mashape.com/3/image’,

  type: 'POST',
  headers: {
	'X-Mashape-Key': MashapeKey,
    Authorization: auth,
    Accept: 'application/json'
  },
  data: {
    image: base64ImgResult,
    type: 'base64'
	 
  },
  success: function(result) {
  var id = result.data.id;
    //window.location = 'https://imgur.com/gallery/' + id;
	
	//imgHostUrl = 'https://i.imgur.com/' + id + ".jpg";
	imgHostUrl = 'https://imgur.com/' + id;
	//window.location = 'https://i.imgur.com/' + id + ".jpg";
	smsSend(imgHostUrl, tel);
	imgurLog ("sent", id);
	
  },
  error: function(jqXHR, status, err) { 
  console.log(formatErrorMessage(jqXHR, status));
	imgurLog ("fail", formatErrorMessage(jqXHR, status));
	smsLog ("fail - imgurUp", "none", tel);

// console.log (jqXHR);
//smsSend();
}
});

}

Join in the discussion - add comment below:

Login / Signup to post new comments