无法使用redmine_oauth_provider从redmine获取oauth请求令牌

时间:2014-02-05 21:36:37

标签: java oauth redmine scribe

我正在尝试使用redmine_oauth_provider插件(https://github.com/a-ono/redmine_oauth_provider)在redmine 2.4.2中使用oauth。

我已经在redmine中配置了一个新客户端,然后获取了消费者密钥和消费者密钥。

然后我尝试使用抄写库(jenkins用来使oauth工作)来做一个例子。

但是我无法获得请求令牌,redmine发送给我一个401正文无效的OAuth请求

这是我写的服务

package org.scribe.builder.api;

import org.scribe.model.Token;

public class RedmineApi extends DefaultApi10a {

    protected final String redmineUrl;

    public RedmineApi(String redmineUrl) {
        redmineUrl = redmineUrl.trim();
        if (!redmineUrl.endsWith("/")) {
            redmineUrl += "/";
        }
        this.redmineUrl = redmineUrl;
    }

    @Override
    public String getAccessTokenEndpoint() {
        return redmineUrl + "access_token";
    }

    @Override
    public String getAuthorizationUrl(Token requestToken) {
        return redmineUrl + "authorize?oauth_token=" + requestToken.getToken();
    }

    @Override
    public String getRequestTokenEndpoint() {
        return redmineUrl + "request_token";
    }
}

客户端测试

    OAuthService service = new ServiceBuilder()
            .provider(new RedmineApi("https://nuiton.org/oauth"))
            .apiKey("XXX")
            .apiSecret("XXX")
            .debug()
            .build();

    Token requestToken = service.getRequestToken();

在运行时我得到了

using Http Header signature
sending request...
response status code: 401
Exception in thread "main" org.scribe.exceptions.OAuthException: Response body is    incorrect. Can't extract token and secret from this: 'Invalid OAuth Request'

在redmine方面,我得到了

Started POST "/oauth/request_token" for 78.216.18.159 at Wed Feb 05 22:30:13 +0100 2014
Processing by OauthController#request_token as HTML
  Current user: anonymous
  Rendered text template (0.0ms)
Filter chain halted as #    <OAuth::Controllers::ApplicationControllerMethods::Filter:0xf533d024 @options={:interactive=>false, :strategies=>:two_legged}, @strategies=[:two_legged]> rendered or redirected
Completed 401 Unauthorized in 3.5ms (Views: 0.6ms | ActiveRecord: 0.6ms)

非常感谢任何帮助。

0 个答案:

没有答案