【问题标题】:oauth version 1 missing authentication credentialsoauth 版本 1 缺少身份验证凭据
【发布时间】:2016-10-16 08:31:58
【问题描述】:

当我尝试执行 OAuth v1 请求时,我得到了

“响应{code=401, message='Unauthorized', body='null', headers={Keep-Alive=timeout=60, Transfer-Encoding=chunked, null=HTTP/1.1 401 Unauthorized, Server=CodeBig , WWW-Authenticate=OAuth realm="classified.net", Connection=keep-alive, CodeBig-Error-Message=missing authentication credentials, Date=Sun, 16 Oct 2016 08:16:16 GMT, Via=1.1 CodeBig, Content -Type=text/plain}}"###

这是使用scribejava

的代码sn-p
String apiKey = "fsfsfsf";
        String apiSecret = "fsfsfsfsf";
        String PROTECTED_RESOURCE_URL = "https://somerealm.net/";
        OAuth10aService service = new ServiceBuilder().apiKey(apiKey).apiSecret(apiSecret).signatureType(SignatureType.QueryString).build(new MyAOuthv1());

OAuthRequest request = new OAuthRequest(Verb.POST, PROTECTED_RESOURCE_URL, service);
request.addOAuthParameter(OAuthConstants.TIMESTAMP, service.getApi().getTimestampService().getTimestampInSeconds());
        request.addOAuthParameter(OAuthConstants.NONCE, service.getApi().getTimestampService().getNonce());
        request.addOAuthParameter(OAuthConstants.CONSUMER_KEY, "blahblahblah");
        request.addOAuthParameter(OAuthConstants.CONSUMER_SECRET, "blahblahblah");
        request.addOAuthParameter(OAuthConstants.SIGN_METHOD, service.getApi().getSignatureService().getSignatureMethod());
        request.addOAuthParameter(OAuthConstants.VERSION, "1.0");
        request.addOAuthParameter(OAuthConstants.SIGNATURE, getSignature(service, request));
request.addPayload("{\"id\":12345,\"message\":\"some text\"}");
request.addHeader("Content-Type", "application/json");

Response response = request.send();

但是,如果我使用 firefox 的 REST 客户端,我可以正常工作。 怎么了? OAuth 版本为 1.0

【问题讨论】:

    标签: oauth


    【解决方案1】:

    为什么不使用 OAuth10aService::signRequest 方法?

    【讨论】:

    • 我没有令牌。
    猜你喜欢
    • 2014-01-05
    • 2015-06-01
    • 2014-01-20
    • 1970-01-01
    • 2021-09-24
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    • 1970-01-01
    相关资源
    最近更新 更多