从BufferedReader获取403 [英] Getting a 403 from BufferedReader

查看:82
本文介绍了从BufferedReader获取403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将图片上传到imgur,我从网站上收到了回复,但返回的却是

I'm trying to upload an image to imgur, I am getting a response from the site but it returns me with

null:{数据":{错误":格式错误的身份验证标头",请求":"/3/图像",参数":图像= iVBORw0KGgoAAAANSUhEUgAAB4AAAASwCAIAAACVUsChAACAAElEQVR42uzdCXebyrI2YEuyY8fZ,"/:" POST},"成功:false,"状态:403}

null : {"data":{"error":"Malformed auth header","request":"/3/image","parameters":"image = iVBORw0KGgoAAAANSUhEUgAAB4AAAASwCAIAAACVUsChAACAAElEQVR42uzdCXebyrI2YEuyY8fzPCbZOyfZd597v///...","method":"POST"},"success":false,"status":403}

imgur文档上的403错误说

A 403 error on the imgur documentation says

禁止.您无权执行此操作.如果遇到此错误,请检查您是否还没有用完API积分,或者确保您正确发送了OAuth标头并具有有效的令牌/秘密.

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.

我知道这个秘密是有效的,并且我有足够的信用,这意味着我没有正确发送OAuth标头.

I know that the secret is valid and that I have enough credits which means I'm not sending the OAuth header properly.

post.addHeader("Authorization", "Client-ID" + clientID);

任何人都想知道的解决方案是该行应该是

The solution for anyone wondering was that that line was supposed to be

post.addHeader("Authorization", "Client-ID " + clientID);

推荐答案

我相信您缺少客户端ID"字符串和实际客户端ID之间的空格.尝试替换它:

I believe you are missing the space between the "Client-ID" string and the actual client id. Try to replace this:

    post.addHeader("Authorization", "Client-ID" + clientID);

使用

    post.addHeader("Authorization", "Client-ID " + clientID);

官方 Imgur身份验证文档说要设置标头,如下所示:

As the official Imgur authentication documentation says to set the header like this:

授权:客户端ID YOUR_CLIENT_ID

Authorization: Client-ID YOUR_CLIENT_ID

希望它能起作用!

这篇关于从BufferedReader获取403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆