Closed itsfolf closed 8 years ago
Hello. Currently @njb_said is on holidays so I'll be helping you today :)
The error is the 403 response code that our server returned. This means that the page is forbidden. This is most likely an issue with Cloudflare blocking your request(s). Have you tried another way of reading the json, perhaps try the URL and URLConnection class?
I would like to add to this by saying I'm receiving the 403 both locally and pushed to the server I'm developing for. I'm using a HttpURLConnection
and a buffered reader to obtain the response data (as I did with Mojang's API previously which worked) like so BufferedReader response = BufferedReader(new InputStreamReader(connection.getInputStream()))
but the reponse headers aren't very useful..
X-Frame-Options:
SAMEORIGIN
Transfer-Encoding:
chunked
null:
HTTP/1.1 403 Forbidden
CF-RAY:
259dedd8529b352a-LHR
Cache-Control:
max-age=10
Server:
cloudflare-nginx
Connection:
keep-alive
Set-Cookie:
__cfduid=df67f96d877c316d407fd587dd6ac0d751450977125; expires=Fri, 23-Dec-16 17:12:05 GMT; path=/; domain=.mc-api.net; HttpOnly
Expires:
Thu, 24 Dec 2015 17:12:15 GMT
Date:
Thu, 24 Dec 2015 17:12:05 GMT
Content-Type:
text/html; charset=UTF-8
I have explicitly defined the content type as application/json on the instance of HttpURLConnection as such: connection.setRequestProperty("Content-Type", "application/json")
and my URL is formatted like so: String url = String.format("https://us.mc-api.net/v3/uuid/%s/json", playerName)
Really not sure about this one but I took a look at your Java implementation and found you use a HttpResponse which might be worth trying on my end but I'd rather not have to re-factor right now. Any insight would be appreciated!
I'd also like add that I could only get it to work by falsifying the User-Agent header.
Ah, in that case it is cloudflare blocking you for an invalid user-agent header, setting that yourself would fix it.
Looks like it was solved. Closing Issue
Well maybe you guys no longer get this issue but unfortunately I still do. It happens with the UUID API in /v3/uuid/notch. I get 403 error.
@dadus33 Ther's two errors, one is the path, and other the name, you should use http://mcapi.ca/uuid/player/Notch , whatever the UUID API isn't working for me at the time I'm writing this, when it gets back up the URL i give to you should work, if not look at the methods above.
@checkplys thanks for that but unfortunately I was trying to switch from mcapi.ca as it's downtime is just huge. What should I try?
Also what do you mean by wrong path or name? The user notch does exist. Also, what's wrong with the path? Seems to be working in browser: http://eu.mc-api.net/v3/uuid/Notch
@dadus33 On the example it shows another path at mc-api.net
Well this is the example: http://prntscr.com/a410jg But anyways, what should I do? Why do I keep getting 403? Please help...
Have you tried setting your user agent header yourself @dadus33 ? It was the fix for this issue originally. Cloudflare likes to block most requests that look like a bot attack or dos which normally don't have proper headers.
@ImNatho Well I'm trying to use it for the UUID fetcher of the SkinsResorer plugin. That currently uses mcapi.ca which is kinda always down -_-. Anyways, I know how to add a custom header but I just don't want to mess up the current code of the plugin as honestly, there are lots of things there I can't understand. However, I'll try, and if I don't manage to solve it I'll tell the author to change it if possible. I'll report back ASAP! Thanks for the idea anyways!
Can I have a link to that plugin? I might write a MC-API patch for it
@ImNatho Of course, it's open source on github, just search for it (SkinsRestorer by Th3Troller). By the way, it looks like I managed to edit those things myself :D
@dadus33 On that repository it doesn't look like it uses mc-api at all https://github.com/Th3Tr0LLeR/SkinsRestorer---Maro/blob/master/src/skinsrestorer/shared/utils/MojangAPI.java#L42
@njb-said Yes, Because I don't know if it bypasses the rate limit. It would be cool to use it if it does :)
We aren't affiliated with mcapi.ca in any way. This is mc-api.net, an entirely seperate service. Just wanted to clear that up in case anyone was confused.
Yes. When i was searching for an API i can use to bypass the limit, i saw your API. It is good, but i don't know if it has limit, or it doesn't have. it can easily be overloaded by the servers using SkinsRestorer.
@dadus33
Download gson and add it to your buildpath: http://central.maven.org/maven2/com/google/code/gson/gson/2.5/gson-2.5.jar Then use this class I made for you: http://pastebin.com/V0e5VHsR
With that, you can just do this:
String UUID = JsonGet.getUUID("player")
@checkplys Thanks for the suggestion but I already managed to get it working. Anyways, I think this issued should now rest in peace. You won't get the 403 error if you use a fake user agent.
@dadus33 As this has happened to a few people now I am going to add a message in the documentation about it until I can think of a better solution.
@Th3Tr0LLeR As for rate limiting, there isn't a "hard" rate limit on my servers that anyone is likely to hit, but it can still get throttled by mojang (not much I can about this other than proxy my traffic + add more servers) I am currently investigating if I need more servers and also looking at a way to proxy my traffic (make it use a different ip address) to fit mojang's silly rate limit.
@njb-said SkinsRestorer is used to restore the skins for the cracked servers. it requests skin data every time a new or un-cached player join. I used to use mcapi.ca, but now it gets overloaded and i don't know what to do now :D
Im trying to use the mc api but I get error 403
My code: json = readUrl("http://eu.mc-api.net/v3/server/info/mc.hypixel.net");
Error: java.io.IOException: Server returned HTTP response code: 403 for URL: http://eu.mc-api.net/v3/server/info/mc.hypixel.net at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.URL.openStream(Unknown Source) at tx.craft.SkypeBot.JP.readUrl(JP.java:25) at tx.craft.SkypeBot.JP.send(JP.java:46) at tx.craft.SkypeBot.Bot$1.chatMessageReceived(Bot.java:34) at com.skype.ChatMessageConnectorListener.fireMessageReceived(ChatMessageConnectorListener.java:76) at com.skype.ChatMessageConnectorListener.messageReceived(ChatMessageConnectorListener.java:51) at com.skype.connector.Connector.fireMessageEvent(Connector.java:1160) at com.skype.connector.Connector.access$500(Connector.java:37) at com.skype.connector.Connector$13.run(Connector.java:1139) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)