Sha*_*arj 14 twitter android oauth twitter4j twitter-oauth
我正在使用Twitter4J库进行OAuth身份验证,但即使在它打开Twitter登录页面之前,我也会收到"身份验证挑战是空的例外".
这是代码.
Twitter twitter = new TwitterFactory().getInstance();
try
{
twitter.setOAuthConsumer(Startup.TWITTER_KEY, Startup.TWITTER_SECRET);
String callbackURL = "twitter-client:///";
RequestToken rToken = twitter.getOAuthRequestToken(callbackURL);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(rToken.getAuthenticationURL())));
}
catch(IllegalStateException e)
{
// access token is already available, or consumer key/secret is not set.
if(!twitter.getAuthorization().isEnabled()){
System.out.println("OAuth consumer key/secret is not set.");
System.exit(-1);
}
}
catch(Exception e)
{
Toast.makeText(Home.this, "Network Host not responding: "+e.getMessage(),Toast.LENGTH_SHORT).show(); //This exception.
}
Run Code Online (Sandbox Code Playgroud)
例外:
E/Home(4393):接收的认证质询为空E/Home(4393):接收的认证质询为null相关的讨论可以在因特网上:E/Home(4393):http: //www.google.co.jp/search?q = 6c607809 或E/Home(4393):http: //www.google.co.jp/search ?q = 0f1d8134 E/Home(4393):TwitterException {exceptionCode = [6c607809-0f1d8134 cab4c0ac-d492a113] ,statusCode = -1,retryAfter = 0,rateLimitStatus = null,version = 2.2.2} E/Home(4393):at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:204)E/Home(4393) :在twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)E/Home(4393):在twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:102)E/Home(4393):at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:108)E/Home(4393):at twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:271)E/Home(4393):at com.sharj.trafik.view. Home.askOAuth(Home.java:157)E/Home(4393):at c om.sharj.trafik.view.Home.access $ 0(Home.java:143)E/Home(4393):at com.sharj.trafik.view.Home $ 3.onClick(Home.java:110)E/Home( 4393):在android.view.View.performClick(View.java:2485)E/Home(4393):在android.view.View $ PerformClick.run(View.java:9080)E/Home(4393):at android.os.Handler.handleCallback(Handler.java:587)E/Home(4393):在android.os.Handler.dispatchMessage(Handler.java:92)E/Home(4393):在android.os.Looper. loop(Looper.java:130)E/Home(4393):在android.app.ActivityThread.main(ActivityThread.java:3683)E/Home(4393):at java.lang.reflect.Method.invokeNative(Native Method) )E/Home(4393):at java.lang.reflect.Method.invoke(Method.java:507)E/Home(4393):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java) :839)E/Home(4393):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)E/Home(4393):at dalvik.system.NativeStart.main(Native Method)E/Home(4393):引起:java.io.IOException:收到身份验证质询 是null E/Home(4393):at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:1153)E/Home(4393):at org.apache. harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:1095)E/Home(4393):at org.apache.harmony.luni.internal.net.www.protocol.http. HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1048)E/Home(4393):at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:726)E/Home( 4393):at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:121)E/Home(4393):at twitter4j.internal.http.HttpResponseImpl.(HttpResponseImpl .java:35)E/Home(4393):在twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:168)E/Home(4393):... 18更多
它包含以下链接,但Google对此没有太多了解.
Joh*_*aby 15
我有同样的问题.事实证明,如果oAuth调用上的时间戳不正确,服务器将返回401状态错误,在Android设备上会导致抛出"Received authentication challenge is null"异常.所有遇到此问题的设备都有不正确的时间,修复时间解决了问题.
也许这也是你的问题?
| 归档时间: |
|
| 查看次数: |
8914 次 |
| 最近记录: |