使用scribe oauth java进行POST时的401响应 [英] 401 response when do a POST using scribe oauth java
本文介绍了使用scribe oauth java进行POST时的401响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用GET时,这不会发生。
This does NOT happen when I use it with a GET.
即。
这不起作用:
ProxyAuthenticator pa = new ProxyAuthenticator();
Authenticator.setDefault( pa );
OAuthService service = new ServiceBuilder().provider( TwitterApi.class ).apiKey( strAPIKey ).apiSecret( strAPISecret ).build();
Token requestToken = service.getRequestToken();
Scanner in = new Scanner( System.in );
Verifier verifier = new Verifier(in.nextLine());
String url = "http://api.twitter.com/1/statuses/update.json?status=helllllooooo";
OAuthRequest request = new OAuthRequest( Verb.POST, url );
service.signRequest( accessToken , request2 );
final Response response = request.send();
响应返回401.但是,使用带有上述代码的GET将返回200作为响应。
ie
Response returns a 401. However, using a GET with the above code returns a 200 in response. i.e.
url = "http://api.twitter.com/1/account/verify_credentials.json";
OAuthRequest request = new OAuthRequest( Verb.GET, url );
service.signRequest( accessToken, request );
Response resp = request.send();
我应该怎么做?
推荐答案
我知道这是用不同的语言提出的,但有些原则是相同的。其中一个答案提到在java中解决这个问题。
I know this is asked about in a different language, but some of the principles are the same. and one of the answers mentions solving this in java.
这篇关于使用scribe oauth java进行POST时的401响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文