401 response when do a POST using scribe oauth java

风格不统一 提交于 2020-01-02 11:19:14

问题


This does NOT happen when I use it with a GET.

i.e.

this DOES NOT WORK:

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();

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();

Any ideas what I should do?


回答1:


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.

Getting 401 on Twitter OAuth POST requests



来源:https://stackoverflow.com/questions/7001629/401-response-when-do-a-post-using-scribe-oauth-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!