0
我有使用OAuth后续POST请求和请求主体POST请求失败由于无效的签名
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "firstname=martin");
Request request = new Request.Builder()
.url("http://127.0.0.1:8080/api/people/new")
.post(body)
.addHeader("authorization", "OAuth oauth_consumer_key=\"5jyytn5guw84os48scckwkkwkkckwkowcgow04g04oc84kg0c4\",oauth_token=\"qwertzuiop\",oauth_signature_method=\"HMAC-SHA1\",oauth_timestamp=\"1465370390\",oauth_nonce=\"rFED5R\",oauth_version=\"1.0\",oauth_signature=\"aU2zedmum%2BwO3I%2FesAv159nLE8o%3D\"")
.addHeader("cache-control", "no-cache")
.addHeader("content-type", "application/x-www-form-urlencoded")
.build();
Response response = client.newCall(request).execute();
问题是请求主体(与窗体-urlencoded参数)和所生成的oauth_signature
。没有身体,我生成的签名是绝对正确的,并且通话很顺利,但是在添加请求主体之后,呼叫失败,出现401 - unauthorized
我认为只有oauth头参数与oauth_signature计算相关?我绝对失去了,并会感谢任何帮助。