Twitter API状态代码401无法验证您的错误{“消息":“无法验证您的身份",“代码":32} [英] Twitter API Status code 401 Could not Authenticate You Error {"message":"Could not authenticate you","code":32}

查看:544
本文介绍了Twitter API状态代码401无法验证您的错误{“消息":“无法验证您的身份",“代码":32}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个获取Twitter趋势的应用程序.....验证身份时遇到问题...

this is an app to get the trends in twitter.....im having trouble in authenticating...

使用用户名和密码对Twitter进行身份验证并重定向回我的应用程序后,出现问题,我得到状态代码401 ,无法针对 GET请求

the problem once i have authenticated into twitter using username and password and after redirecting back to my app i get the status code 401 could not authenticate for the GET request https://api.twitter.com/1.1/trends/available.json.

我认为问题出在get请求的auth标头中

I think the problem is in auth header for the get request

{错误":[{"消息":无法验证您的身份",代码":32}]}.

请帮助我

先谢谢您了:)

这里是我的身份验证类--AuthActivity.java

package com.tmm.android.twitter;


import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.Random;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import oauth.signpost.OAuthProvider;
import oauth.signpost.basic.DefaultOAuthProvider;
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.http.AccessToken;
import twitter4j.http.BASE64Encoder;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.tmm.android.twitter.appliaction.TwitterApplication;
import com.tmm.android.twitter.util.Constants;



public class AuthActivity extends Activity {

private Twitter twitter;
private OAuthProvider provider;
private CommonsHttpOAuthConsumer consumer;

private String CONSUMER_KEY =           Constants.CONSUMER_KEY;
private String CONSUMER_SECRET =        Constants.CONSUMER_SECRET;
private String CALLBACK_URL =           "https://www.google.co.in";

private Button buttonLogin;

SharedPreferences sharedPrefs=null;;
String verifiers=null;


String oauth_consumer_key="3pNHYDmpWsMGQry8V1Ohw";
String oauth_consumer_secret="YwB8KZNimt6tmBHqOMQFw75k3bEDaiw1WBcru3RRS8";

public static String oauth_nonce=null;

final String oauth_timestamp1=String.valueOf(new Date().getTime());
final String oauth_timestamp=oauth_timestamp1.substring(0, 10);

public static String oauth_signature=null;
String oauth_signature_method="HMAC-SHA1";  
public static String oauth_token; //access_token
String oauth_version="1.0";

public static String access_token_secret;
String secret;


@Override
public void onCreate(Bundle savedInstanceState) {
    System.setProperty("http.keepAlive", "false");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_oauth);        


    //check for saved log in details..
    checkForSavedLogin();

    //set consumer and provider on teh Application service
    getConsumerProvider();

    //Define login button and listener
    buttonLogin = (Button)findViewById(R.id.ButtonLogin);
    buttonLogin.setOnClickListener(new OnClickListener() {  
        public void onClick(View v) {

            Log.d("timestamp1",oauth_timestamp);
            askOAuth(); 


        }
    });
}




private void checkForSavedLogin() {
    // Get Access Token and persist it
    AccessToken a = getAccessToken();
    if (a==null) return;    //if there are no credentials stored then return to usual activity

    // initialize Twitter4J
    twitter = new TwitterFactory().getInstance();
    twitter.setOAuthConsumer(CONSUMER_SECRET, CONSUMER_SECRET);
    twitter.setOAuthAccessToken(a);
    ((TwitterApplication)getApplication()).setTwitter(twitter);

    startFirstActivity();
    //finish();
}

/**
 * Kick off the activity to display 
 */
private void startFirstActivity() {
    System.out.println("STARTING FIRST ACTIVITY!");
    Intent i = new Intent(this, TweetsActivity.class);
    startActivity(i);
}

/**
 * This method checks the shared prefs to see if we have persisted a user token/secret
 * if it has then it logs on using them, otherwise return null
 * 
 * @return AccessToken from persisted prefs
 */
private AccessToken getAccessToken() {
    SharedPreferences settings = getSharedPreferences(Constants.PREFS_NAME, MODE_PRIVATE);
    String token = settings.getString("accessTokenToken", "");
    String tokenSecret = settings.getString("accessTokenSecret", "");
    if (token!=null && tokenSecret!=null && !"".equals(tokenSecret) && !"".equals(token)){
        return new AccessToken(token, tokenSecret);
    }
    return null;
}



/**
 * Open the browser and asks the user to authorize the app.
 * Afterwards, we redirect the user back here!
 */
private void askOAuth() {
    try {
        //          Log.e("timestamp",oauth_timestamp);
        //          Log.e("timestampbytes", oauth_timestamp.getBytes().toString());
        //          Log.e("nonce",oauth_nonce);

        Log.e("authUrl1", "hello");
        consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
        provider = new DefaultOAuthProvider("https://api.twitter.com/oauth/request_token", "https://api.twitter.com/oauth/access_token", "https://api.twitter.com/oauth/authorize");

        String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL); //auth_token
        Log.e("authUrl", authUrl);

        String request_token=consumer.getToken();
        String request_token_secret=consumer.getTokenSecret();

        Log.d("request_token",request_token);
        Log.d("request_token_secret",request_token_secret);

        Toast.makeText(this, "Please authorize this app!", Toast.LENGTH_LONG).show();
        setConsumerProvider();

        Intent web_i = new Intent (AuthActivity.this,Webview.class);
        web_i.putExtra("url", authUrl);
        startActivity(web_i);  


        //this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));

    } catch (Exception e) {
        Log.e("exception1", e.getMessage());
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
    }
}


/**
 * As soon as the user successfully authorized the app, we are notified
 * here. Now we need to get the verifier from the callback URL, retrieve
 * token and token_secret and feed them to twitter4j (as well as
 * consumer key and secret).
 */
@Override
protected void onResume() {
    super.onResume();
    System.out.println("RESUMING!!");

    sharedPrefs = getSharedPreferences("sharedprefs", 0);
        verifiers=sharedPrefs.getString("verifiers", "hello");
        Log.d("verifiers",verifiers);
        if(verifiers!="hello")
        {
        dealWithTwitterResponse();
        }

}


 public void dealWithTwitterResponse()
 {
     if(verifiers!=null)
     {

            try {
                // this will populate token and token_secret in consumer
                provider.retrieveAccessToken(consumer, verifiers);

                String accessss_token=consumer.getToken();
                String accessss_token_secret=consumer.getTokenSecret();

                oauth_token=accessss_token;

                access_token_secret=accessss_token_secret;
                Log.d("accessss_token",accessss_token);
                Log.d("accessss_token_secret",accessss_token_secret);


                // Get Access Token and persist it
                AccessToken a = new AccessToken(consumer.getToken(), consumer.getTokenSecret());

                Log.d("access_token", a.toString());
                storeAccessToken(a);

                // initialize Twitter4J
                twitter = new TwitterFactory().getInstance();
                twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);

                twitter.setOAuthAccessToken(a);
                ((TwitterApplication)getApplication()).setTwitter(twitter);
                //Log.e("Login", "Twitter Initialised");


                String randomnum=random();
                oauth_nonce=randomnum+oauth_timestamp;

                Log.d("nonce",oauth_nonce);
                Log.d("timestamp2",oauth_timestamp);



                //  String signatureBaseString ="GET&https%3A%2F%2Fapi.twitter.com%2F1.1%2Ftrends%2Fplace.json&id%3D1%26oauth_consumer_key%3D"+oauth_consumer_key+"%26oauth_nonce%3D"+oauth_nonce+"%26oauth_signature_method%3D"+oauth_signature_method+"%26oauth_timestamp%3D"+oauth_timestamp+"%26oauth_token%3D"+oauth_token+"%26oauth_version%3D"+oauth_version;

                String signatureBaseString ="GET&https%3A%2F%2Fapi.twitter.com%2F1.1%2Ftrends%2Favailable.json&oauth_consumer_key%3D"+oauth_consumer_key+"%26oauth_nonce%3D"+oauth_nonce+"%26oauth_signature_method%3D"+oauth_signature_method+"%26oauth_timestamp%3D"+oauth_timestamp+"%26oauth_token%3D"+oauth_token+"%26oauth_version%3D"+oauth_version;

                Log.d("signatureBaseString", signatureBaseString);

                secret=oauth_consumer_secret+"&"+access_token_secret;

                Log.d("secrets", secret);

                String toHash = URLEncoder.encode(signatureBaseString);
                String hash;
                try {
                    hash = computeHmac(toHash, secret);
                    oauth_signature=hash;
                    Log.d("signature", oauth_signature);                            

                    String sign=URLEncoder.encode(oauth_signature);
                    Log.d("sign", sign);

                    oauth_signature=sign;




                } catch (InvalidKeyException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (NoSuchAlgorithmException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }


                startFirstActivity();

            } catch (Exception e) {
                //Log.e(APP, e.getMessage());
                e.printStackTrace();
                Log.e("exception2", e.getMessage());
                Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
                }
        }
     //     }
    else
    {
        Log.e("error","error");
    }
}
 // }


/**
 * This method persists the Access Token information so that a user
 * is not required to re-login every time the app is used
 * 
 * @param a - the access token
 */
private void storeAccessToken(AccessToken a) {
    SharedPreferences settings = getSharedPreferences(Constants.PREFS_NAME, MODE_PRIVATE);
    SharedPreferences.Editor editor = settings.edit();

    Log.d("a.token",a.getToken());
    Log.d("a.token_secret",a.getTokenSecret());

    editor.putString("accessTokenToken", a.getToken());
    editor.putString("accessTokenSecret", a.getTokenSecret());
    editor.commit();
}


/**
 * Get the consumer and provider from the application service (in the case that the
 * activity is restarted so the objects are not lost
 */
private void getConsumerProvider() {
    OAuthProvider p = ((TwitterApplication)getApplication()).getProvider();
    if (p!=null){
        provider = p;
    }
    CommonsHttpOAuthConsumer c = ((TwitterApplication)getApplication()).getConsumer();
    if (c!=null){
        consumer = c;
    }
}


/**
 * Set the consumer and provider from the application service (in the case that the
 * activity is restarted so the objects are not lost)
 */
private void setConsumerProvider() {
    if (provider!=null){
        ((TwitterApplication)getApplication()).setProvider(provider);
    }
    if (consumer!=null){
        ((TwitterApplication)getApplication()).setConsumer(consumer);
    }
}


public String random()
{
    char[] chars = "abcdefghijklmnopqrstuvwxyz0123456789".toCharArray();
    StringBuilder sb = new StringBuilder();
    Random random = new Random();
    for (int i = 0; i < 22; i++) {
        char c = chars[random.nextInt(chars.length)];
        sb.append(c);
    }
    String output = sb.toString();
    //System.out.println(output);
    return output;
}

public String computeHmac(String baseString, String key) throws InvalidKeyException, NoSuchAlgorithmException
{
    Mac mac = Mac.getInstance("HmacSHA1");
    SecretKeySpec secret = new SecretKeySpec(key.getBytes(), mac.getAlgorithm());
    mac.init(secret);
    byte[] digest = mac.doFinal(baseString.getBytes());

    return new String(BASE64Encoder.encode(digest));
}

}

继承我的TEETS活动类TweetsActivity.java

package com.tmm.android.twitter;

import org.json.JSONArray;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class TweetsActivity extends Activity {

//AuthActivity aa;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    //aa=new AuthActivity(); 

    String TAG_NAME="name";


    //      String url="https://api.twitter.com/1.1/trends/place.json";

    String url="https://api.twitter.com/1.1/trends/available.json";


    Log.e("json url2",url);
    JSONParser jparser=new JSONParser();
    JSONArray json= jparser.getJSONfromURL(url);


    }


**}

HERES MY JSON PARSER CLASS --JSONParser.java **

HERES MY JSON PARSER CLASS --JSONParser.java**

package com.tmm.android.twitter;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import android.util.Log;

public class JSONParser {


JSONArray jarray;

AuthActivity aa;

public JSONParser() {

}

public JSONArray getJSONfromURL(String url)
{
    aa=new AuthActivity(); 

    StringBuilder sb=new StringBuilder();
    HttpClient httpclient =new DefaultHttpClient();
    HttpGet httpget=new HttpGet(url);
//      HttpParams params=new BasicHttpParams();
//      params.setParameter("id", "1");

    String hurl= "OAuth oauth_consumer_key=\""+aa.oauth_consumer_key+"\", oauth_nonce=\""+aa.oauth_nonce+"\", oauth_signature=\""+aa.oauth_signature+"\", oauth_signature_method=\""+aa.oauth_signature_method+"\", oauth_timestamp=\""+aa.oauth_timestamp+"\", oauth_token=\""+aa.oauth_token+"\", oauth_version=\""+aa.oauth_version+"\"";


    httpget.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");       
    httpget.setHeader("Authorization",hurl);
 //     httpget.setParams(params);

    Log.d("oathheaders",hurl);

    try
    {
        HttpResponse httpresponse= httpclient.execute(httpget); 

        StatusLine statusLine= httpresponse.getStatusLine();
        int statusCode= statusLine.getStatusCode();

        Log.d("status code",String.valueOf(statusCode));
        //          if(statusCode==200)
        //          {
            HttpEntity httpentity = httpresponse.getEntity();

            InputStream content= httpentity.getContent();


            BufferedReader br=new BufferedReader(new InputStreamReader(content));
            String line;

            while((line=br.readLine())!=null)
            {
                sb.append(line);                    
            }

            System.out.println(sb.toString());

//          }
//          else
//          {
//              Log.e("error", "FAILED TO DOWNLOAD FILE");
//          }
    }
    catch (ClientProtocolException e) {
        e.printStackTrace();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    catch (Exception e) {
        e.printStackTrace();
    }   


    try
    {
        jarray= new JSONArray(sb.toString());
    }
    catch (JSONException e1) 
    {
        Log.e("parseerror", "Error parsing data "+e1.toString());
    }
    return jarray;

    }

}

在我的LOGCAT中显示错误和Log.d值

HERES MY LOGCAT SHOWING ERRORS AND Log.d Values

03-27 17:00:26.533: D/dalvikvm(13599): Late-enabling CheckJNI
03-27 17:00:27.638: I/System.out(13599): RESUMING!!
03-27 17:00:27.638: D/verifiers(13599): hello
03-27 17:00:29.288: D/GestureDetector(13599): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 3 mFalseSizeCnt:0
03-27 17:00:29.353: D/timestamp1(13599): 1395919827
03-27 17:00:29.353: E/authUrl1(13599): hello
03-27 17:00:32.708: D/dalvikvm(13599): GC_CONCURRENT freed 290K, 8% free 12286K/13319K, paused 113ms+17ms, total 210ms
03-27 17:00:33.813: E/authUrl(13599): https://api.twitter.com/oauth/authorize?oauth_token=LyX3bXZifIBKgh0c5n0PHb8YVUB6Tp1JEd2wziDT4l8
03-27 17:00:33.813: D/request_token(13599): LyX3bXZifIBKgh0c5n0PHb8YVUB6Tp1JEd2wziDT4l8
03-27 17:00:33.813: D/request_token_secret(13599): dZTuoka9tkdZmaHXqcs9v3hHksh2EQ89wWh6uX6o
03-27 17:00:34.928: I/webclipboard(13599): clipservice: android.sec.clipboard.ClipboardExManager@41de1618
03-27 17:00:35.148: D/authorization url(13599): https://api.twitter.com/oauth/authorize?oauth_token=LyX3bXZifIBKgh0c5n0PHb8YVUB6Tp1JEd2wziDT4l8
03-27 17:00:35.173: D/WebView(13599): loadUrlImpl: called
03-27 17:00:35.183: D/dalvikvm(13599): GC_CONCURRENT freed 327K, 9% free 12418K/13511K, paused 14ms+19ms, total 80ms
03-27 17:00:35.253: I/Choreographer(13599): Skipped 40 frames!  The application may be doing too much work on its main thread.
03-27 17:00:35.293: E/webview(13599): registerForStylusPenEvent onAttachedToWindow
03-27 17:00:35.293: E/webview(13599): registerForStylusPenEvent START
03-27 17:00:35.303: E/webview(13599): registerForStylusPenEvent END
03-27 17:00:35.358: D/WebView(13599): onSizeChanged - w:320 h:467
03-27 17:00:35.633: E/SpannableStringBuilder(13599): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
03-27 17:00:35.643: E/SpannableStringBuilder(13599): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
03-27 17:00:35.768: V/webkit(13599): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {41ddb2b0}
03-27 17:00:35.858: D/webcore(13599):  CORE loadUrl: called
03-27 17:00:35.858: D/webkit(13599): Firewall not null
03-27 17:00:35.863: D/webkit(13599): euler: isUrlBlocked = false
03-27 17:00:38.273: I/System.out(13599): RESUMING!!
03-27 17:00:38.278: D/verifiers(13599): hello
03-27 17:00:38.343: W/IInputConnectionWrapper(13599): getSelectedText on inactive InputConnection
03-27 17:00:38.343: W/IInputConnectionWrapper(13599): setComposingText on inactive InputConnection
03-27 17:00:38.418: E/webview(13599): removeForStylusPenEvent onDetachedFromWindow
03-27 17:00:38.418: E/webview(13599): removeForStylusPenEvent START
03-27 17:00:38.418: E/webview(13599): removeForStylusPenEvent END
03-27 17:00:44.448: I/GATE(13599): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
03-27 17:00:50.858: D/GestureDetector(13599): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 3 mFalseSizeCnt:0
03-27 17:00:50.863: D/timestamp1(13599): 1395919827
03-27 17:00:50.863: E/authUrl1(13599): hello
03-27 17:00:52.833: D/dalvikvm(13599): GC_CONCURRENT freed 395K, 9% free 12461K/13639K, paused 24ms+10ms, total 142ms
03-27 17:00:53.728: E/authUrl(13599): https://api.twitter.com/oauth/authorize?oauth_token=JisvmQahwUKUPqM1YTF9GE7aWtE7jIXxAsHsUmyJR5I
03-27 17:00:53.728: D/request_token(13599): JisvmQahwUKUPqM1YTF9GE7aWtE7jIXxAsHsUmyJR5I
03-27 17:00:53.733: D/request_token_secret(13599): 9B5DvKITcjv1elvCE0jF1BpOHgkFFY8Rk3eXUDV0g
03-27 17:00:54.063: V/webkit(13599): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {41e0db88}
03-27 17:00:54.068: I/webclipboard(13599): clipservice: android.sec.clipboard.ClipboardExManager@41e0b6b0
03-27 17:00:54.083: D/authorization url(13599): https://api.twitter.com/oauth/authorize?oauth_token=JisvmQahwUKUPqM1YTF9GE7aWtE7jIXxAsHsUmyJR5I
03-27 17:00:54.088: D/WebView(13599): loadUrlImpl: called
03-27 17:00:54.088: D/webcore(13599):  CORE loadUrl: called
03-27 17:00:54.093: D/webkit(13599): Firewall not null
03-27 17:00:54.093: D/webkit(13599): euler: isUrlBlocked = false
03-27 17:00:54.108: E/webview(13599): registerForStylusPenEvent onAttachedToWindow
03-27 17:00:54.108: E/webview(13599): registerForStylusPenEvent START
03-27 17:00:54.108: E/webview(13599): registerForStylusPenEvent END
03-27 17:00:54.133: D/WebView(13599): onSizeChanged - w:320 h:467
03-27 17:00:54.203: E/SpannableStringBuilder(13599): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
03-27 17:00:54.203: E/SpannableStringBuilder(13599): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
03-27 17:00:56.538: D/GestureDetector(13599): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 5 mFalseSizeCnt:0
03-27 17:00:56.538: V/WebViewInputDispatcher(13599): blockWebkitDraw
03-27 17:00:56.538: V/WebViewInputDispatcher(13599): blockWebkitDraw lockedfalse
03-27 17:00:56.543: V/webview(13599):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 17:00:56.843: D/webview(13599): blockWebkitViewMessage= false
03-27 17:00:57.668: I/GATE(13599): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
03-27 17:00:59.163: D/GestureDetector(13599): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 4 mFalseSizeCnt:0
03-27 17:00:59.163: V/WebViewInputDispatcher(13599): blockWebkitDraw
03-27 17:00:59.163: V/WebViewInputDispatcher(13599): blockWebkitDraw lockedfalse
03-27 17:00:59.168: V/webview(13599):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 17:00:59.468: D/webview(13599): blockWebkitViewMessage= false
03-27 17:00:59.568: D/webcoreglue(13599): WebViewCore::nextTextOrSelectNode : Broken after finding a focusable Node
03-27 17:00:59.568: D/webcoreglue(13599): WebViewCore::nextTextOrSelectNode : Final Next Nodename = <INPUT>, tagname = <INPUT>
03-27 17:00:59.568: D/webcoreglue(13599): WebViewCore::previousTextOrSelectNode :  !previousNode )
03-27 17:00:59.948: D/WebView(13599): onSizeChanged - w:320 h:219
03-27 17:01:38.863: D/dalvikvm(13599): GC_FOR_ALLOC freed 183K, 9% free 12590K/13831K, paused 16ms, total 16ms
03-27 17:01:39.348: D/GestureDetector(13599): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 19 mFalseSizeCnt:0
03-27 17:01:39.348: V/WebViewInputDispatcher(13599): blockWebkitDraw
03-27 17:01:39.348: V/WebViewInputDispatcher(13599): blockWebkitDraw lockedfalse
03-27 17:01:39.348: V/webview(13599):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 17:01:39.913: D/GestureDetector(13599): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 3 mFalseSizeCnt:0
03-27 17:01:39.913: V/WebViewInputDispatcher(13599): blockWebkitDraw
03-27 17:01:39.913: V/WebViewInputDispatcher(13599): blockWebkitDraw lockedfalse
03-27 17:01:39.913: V/webview(13599):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 17:01:40.213: D/webview(13599): blockWebkitViewMessage= false
03-27 17:01:40.243: D/webcoreglue(13599): WebViewCore::nextTextOrSelectNode :  nextNode is NULL
03-27 17:01:40.308: D/webcoreglue(13599): WebViewCore::previousTextOrSelectNode : Broken after finding a focusable Node
03-27 17:01:40.308: D/webcoreglue(13599): WebViewCore::previousTextOrSelectNode : Final Previous Nodename = <INPUT>, tagname = <INPUT>
03-27 17:01:40.433: W/IInputConnectionWrapper(13599): getSelectedText on inactive InputConnection
03-27 17:01:40.558: W/IInputConnectionWrapper(13599): getTextBeforeCursor on inactive InputConnection
03-27 17:01:41.078: W/IInputConnectionWrapper(13599): getTextAfterCursor on inactive InputConnection
03-27 17:01:58.828: D/GestureDetector(13599): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 14 mFalseSizeCnt:0
03-27 17:01:58.828: V/WebViewInputDispatcher(13599): blockWebkitDraw
03-27 17:01:58.828: V/WebViewInputDispatcher(13599): blockWebkitDraw lockedfalse
03-27 17:01:58.828: V/webview(13599):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 17:01:59.268: D/GestureDetector(13599): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 2 mFalseSizeCnt:0
03-27 17:01:59.268: V/WebViewInputDispatcher(13599): blockWebkitDraw
03-27 17:01:59.268: V/WebViewInputDispatcher(13599): blockWebkitDraw lockedfalse
03-27 17:01:59.268: V/webview(13599):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 17:01:59.573: D/webview(13599): blockWebkitViewMessage= false
03-27 17:01:59.823: D/dalvikvm(13599): GC_FOR_ALLOC freed 219K, 9% free 12655K/13831K, paused 18ms, total 19ms
03-27 17:01:59.823: I/dalvikvm-heap(13599): Grow heap (frag case) to 13.331MB for 279056-byte allocation
03-27 17:01:59.848: D/dalvikvm(13599): GC_FOR_ALLOC freed 13K, 9% free 12914K/14151K, paused 18ms, total 18ms
03-27 17:01:59.913: D/WebView(13599): onSizeChanged - w:320 h:467
03-27 17:02:06.438: D/GestureDetector(13599): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 2 mFalseSizeCnt:0
03-27 17:02:11.563: I/GATE(13599): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
03-27 17:02:11.593: D/client 1(13599): https://www.google.co.in/?oauth_token=JisvmQahwUKUPqM1YTF9GE7aWtE7jIXxAsHsUmyJR5I&oauth_verifier=mh9kppYyCpqKKQJvNzvQJq7Jfpc6f2rZHWCryMAzCU
03-27 17:02:11.598: D/WebView(13599): loadUrlImpl: called
03-27 17:02:11.598: D/client 2(13599): client2
03-27 17:02:11.618: D/veri(13599): mh9kppYyCpqKKQJvNzvQJq7Jfpc6f2rZHWCryMAzCU
03-27 17:02:11.663: D/WebCore(13599): uiOverrideUrlLoading: shouldOverrideUrlLoading() returnstrue
03-27 17:02:11.668: D/webcore(13599):  CORE loadUrl: called
03-27 17:02:11.668: D/webkit(13599): Firewall not null
03-27 17:02:11.668: D/webkit(13599): euler: isUrlBlocked = false
03-27 17:02:11.713: I/System.out(13599): RESUMING!!
03-27 17:02:11.713: D/verifiers(13599): mh9kppYyCpqKKQJvNzvQJq7Jfpc6f2rZHWCryMAzCU
03-27 17:02:12.153: D/dalvikvm(13599): GC_CONCURRENT freed 544K, 10% free 12810K/14151K, paused 12ms+5ms, total 38ms
03-27 17:02:14.423: D/accessss_token(13599): 100169976-iH3DymZLLlVXyXm3VaY48BnBRfzfDjRmqsWbuaOR
03-27 17:02:14.423: D/accessss_token_secret(13599): JfBbgSoefa1iNqCC0Yh7yQkpMwvBTQPVIFXUoxP6Qs6Ne
03-27 17:02:14.428: D/access_token(13599): AccessToken{screenName='null', userId=0}
03-27 17:02:14.428: D/a.token(13599): 100169976-iH3DymZLLlVXyXm3VaY48BnBRfzfDjRmqsWbuaOR
03-27 17:02:14.428: D/a.token_secret(13599): JfBbgSoefa1iNqCC0Yh7yQkpMwvBTQPVIFXUoxP6Qs6Ne
03-27 17:02:14.488: D/nonce(13599): gsrtrvq124n36raqmf2mdi1395919827
03-27 17:02:14.488: D/timestamp2(13599): 1395919827
03-27 17:02:14.488: D/signatureBaseString(13599): GET&https%3A%2F%2Fapi.twitter.com%2F1.1%2Ftrends%2Favailable.json&oauth_consumer_key%3D3pNHYDmpWsMGQry8V1Ohw%26oauth_nonce%3Dgsrtrvq124n36raqmf2mdi1395919827%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1395919827%26oauth_token%3D100169976-iH3DymZLLlVXyXm3VaY48BnBRfzfDjRmqsWbuaOR%26oauth_version%3D1.0
03-27 17:02:14.488: D/secrets(13599): YwB8KZNimt6tmBHqOMQFw75k3bEDaiw1WBcru3RRS8&JfBbgSoefa1iNqCC0Yh7yQkpMwvBTQPVIFXUoxP6Qs6Ne
03-27 17:02:14.498: D/signature(13599): sp6n3AagNKYFpno7XfU/zZ2zmck=
03-27 17:02:14.498: D/sign(13599): sp6n3AagNKYFpno7XfU%2FzZ2zmck%3D
03-27 17:02:14.498: I/System.out(13599): STARTING FIRST ACTIVITY!
03-27 17:02:14.508: D/dalvikvm(13599): GC_CONCURRENT freed 508K, 11% free 12710K/14151K, paused 12ms+2ms, total 39ms
03-27 17:02:14.513: I/Choreographer(13599): Skipped 158 frames!  The application may be doing too much work on its main thread.
03-27 17:02:14.653: E/json url2(13599): https://api.twitter.com/1.1/trends/available.json
03-27 17:02:14.658: D/oathheaders(13599): OAuth oauth_consumer_key="3pNHYDmpWsMGQry8V1Ohw", oauth_nonce="gsrtrvq124n36raqmf2mdi1395919827", oauth_signature="sp6n3AagNKYFpno7XfU%2FzZ2zmck%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1395919934", oauth_token="100169976-iH3DymZLLlVXyXm3VaY48BnBRfzfDjRmqsWbuaOR", oauth_version="1.0"
03-27 17:02:15.398: I/GATE(13599): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
03-27 17:02:17.133: D/dalvikvm(13599): GC_CONCURRENT freed 305K, 10% free 12799K/14151K, paused 9ms+10ms, total 82ms
03-27 17:02:17.598: W/DefaultRequestDirector(13599): Authentication error: Unable to respond to any of these challenges: {}
03-27 17:02:17.598: D/status code(13599): 401
03-27 17:02:17.603: I/System.out(13599): {"errors":[{"message":"Could not authenticate you","code":32}]}
03-27 17:02:17.613: E/parseerror(13599): Error parsing data org.json.JSONException: Value {"errors":[{"message":"Could not authenticate you","code":32}]} of type org.json.JSONObject cannot be converted to JSONArray
03-27 17:02:17.628: I/Choreographer(13599): Skipped 170 frames!  The application may be doing too much work on its main thread.

推荐答案

根据 https://tweetinvi.codeplex.com/documentation

请确认您的机器时间设置正确(两者均时间和区域).时间不正确可能会导致收到 401 异常.

Please verify that the time of your machine is correctly setup (both the time and the region). Having an incorrect Time can result in receiving the 401 exception.

如果不是这种情况,请点击以下链接可能会有所帮助:

If this is not the case then following links which might be helpful:

为什么

401错误流API

Twitter API集成-远程服务器返回错误:(401)未经授权

这篇关于Twitter API状态代码401无法验证您的错误{“消息":“无法验证您的身份",“代码":32}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆