0

開発者フォーラムで見た例の 1 つを使用して、OAuth と Signpost で Evernote に接続しようとしていますが、何らかの理由でエラー コード 400 (Bad Request) が表示され続けます。コードは次のとおりです。

public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub
        String consumerKey = "key_here";
        String consumerSecret = "secret_key_here";

        OAuthConsumer consumer = new DefaultOAuthConsumer(consumerKey,
                consumerSecret);
        consumer.setMessageSigner(new PlainTextMessageSigner());
        OAuthProvider provider = new DefaultOAuthProvider(
                "https://sandbox.evernote.com/oauth",
                "https://sandbox.evernote.com/oauth",
                "https://sandbox.evernote.com/OAuth.action") {
            private static final long serialVersionUID = 1L;

            @Override
            protected HttpRequest createRequest(String endpointUrl)
                    throws MalformedURLException, IOException {
                HttpURLConnection connection = (HttpURLConnection) new URL(
                        endpointUrl).openConnection();
                connection.setRequestMethod("GET");
                connection.setAllowUserInteraction(false);
                connection.setRequestProperty("Content-Length", "0");
                return new HttpURLConnectionRequestAdapter(connection);
            }
        };
        String authUrl = provider.retrieveRequestToken(consumer,
                OAuth.OUT_OF_BAND);
        System.out.println(authUrl);
    }

(そして、誰かが尋ねる前に、はい、プレースホルダーを自分のキーに置き換えました)そして、ここにエラーがあります:

Exception in thread "main" oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: Service provider responded in error: 400 (Bad Request)
    at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:218)
    at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:74)
    at com.zakta.evernote.module.EvernoteAuthenticationTest.main(EvernoteAuthenticationTest.java:44)
Caused by: oauth.signpost.exception.OAuthCommunicationException: Service provider responded in error: 400 (Bad Request)
    at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:245)
    at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:193)
    ... 2 more

ここでは正しい手順を使用しているようですが、何か変わったのでしょうか? 助けてくれてありがとう。

4

1 に答える 1

0

現在の Evernote OAuth は OUT_OF_BOUND を許可していません。コールバック URL を渡す必要があります。

于 2013-07-16T21:46:09.517 に答える