0

これらのサイトの両方で、トークンシークレットとコンシューマーシークレットを要求します:http: //oauth.googlecode.com/svn/code/javascript/example/signature.html http://developer.netflix.com/resources/OAuthTest#instructions

プログラムで設定するにはどうすればよいですか。

public void excecuteSigning(String targetURL){
            HttpRequestAdapter requestSig = new HttpRequestAdapter(new HttpGet("http://photos.example.net/photos"));
            HttpParameters requestparameters = new HttpParameters();
            OAuthMessageSigner signer = new HmacSha1MessageSigner();

requestparameters.put(OAuth.OAUTH_CONSUMER_KEY, "dpf43f3p2l4k3l03");        
            requestparameters.put(OAuth.OAUTH_TOKEN, "nnch734d00sl2jdk");
            requestparameters.put(OAuth.OAUTH_NONCE, "kllo9940pd9333jh");
            requestparameters.put(OAuth.OAUTH_TIMESTAMP, "1191242096");
            requestparameters.put(OAuth.OAUTH_SIGNATURE_METHOD, "HMAC-SHA1");
            requestparameters.put(OAuth.OAUTH_VERSION, "1.0");
            requestparameters.put("size", "original");
            requestparameters.put("file", "vacation.jpg");
            String OAUTH_SIG = signer.sign(requestSig, requestparameters);
            System.out.println(OAUTH_SIG);
}

///上記はこの署名を生成します:rYexRY70p6aDDWw0ox0SwERRK2w =

///以下のコードは正しい署名を生成しません

requestparameters.put("oauth_consumer_secret", "kd94hf93k423kf44");
            requestparameters.put(OAuth.OAUTH_TOKEN_SECRET, "pfkkdhi9sl3r4s00");
4

2 に答える 2

0
OAuthMessageSigner signer = new HmacSha1MessageSigner();
     signer.setConsumerSecret(consumerSecret);
     signer.setTokenSecret(tokenSecret);

正常に動作し、正しい署名を生成します。

于 2012-04-16T22:41:41.007 に答える
0

クライアントの完全なソース コードを含めてください。あなたが提供した値を使用して、Google OAuth テスト リンクはこの署名を提供します -

OAuth realm="",oauth_version="1.0",oauth_consumer_key="dpf43f3p2l4k3l03",oauth_token="nnch734d00sl2jdk",oauth_timestamp="1191242096",oauth_nonce="kllo9940pd9333jh",oauth_signature_method="HMAC-SHA1",oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D"

クライアントが生成する署名値は?

于 2012-04-16T19:18:28.487 に答える