Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6888493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:01:31+00:00 2026-05-27T06:01:31+00:00

I am using an application to authorize a user in Twitter using Twitter4j library.

  • 0

I am using an application to authorize a user in Twitter using Twitter4j library. I want to incorporate a feature, my mobile app opens. It has a login button on click of which Twitter login dialog appears and lets you enter the login information . after the login is complete, another screen opens.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;

import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
import twitter4j.auth.RequestToken;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.Toast;

public class AndTweetVJActivity extends Activity {
    /** Called when the activity is first created. */


    Twitter twitter;
    RequestToken requestToken;
    public final static String consumerKey = "myKey"; // "your key here";
    public final static String consumerSecret = "myKey"; // "your secret key here";
    private final String CALLBACKURL = "T4JOAuth://main";  //Callback URL that tells the WebView to load this activity when it finishes with twitter.com. (see manifest)


        //Calls the OAuth login method as soon as its started
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            OAuthLogin();
        }

        /* Creates object of Twitter and sets consumerKey and consumerSecret
         * - Prepares the URL accordingly and opens the WebView for the user to provide sign-in details
         * - When user finishes signing-in, WebView opens your activity back  */

        void OAuthLogin() {
            try {
                twitter = new TwitterFactory().getInstance();
                twitter.setOAuthConsumer(consumerKey, consumerSecret);
                requestToken = twitter.getOAuthRequestToken(CALLBACKURL);
                String authUrl = requestToken.getAuthenticationURL();
                this.startActivity(new Intent(Intent.ACTION_VIEW, Uri
                        .parse(authUrl)));
            } catch (TwitterException ex) {
                Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
                Log.e("in Main.OAuthLogin", ex.getMessage());
            }
        }


        /*
         * - Called when WebView calls your activity back.(This happens when the user has finished signing in)
         * - Extracts the verifier from the URI received
         * - Extracts the token and secret from the URL 
         */
        @Override
        protected void onNewIntent(Intent intent) {
            super.onNewIntent(intent);
            Uri uri = intent.getData();
            try {
                String verifier = uri.getQueryParameter("oauth_verifier");
                AccessToken accessToken = twitter.getOAuthAccessToken(requestToken,verifier);
                String token = accessToken.getToken(), secret = accessToken.getTokenSecret();
                //displayTimeLine(token, secret); //after everything, display the first tweet 

            } catch (TwitterException ex) {
                Log.e("Main.onNewIntent", "" + ex.getMessage());
            }

        }
    }

however on running this application, it gives me error in logcat :

11-18 10:36:27.727: E/in Main.OAuthLogin(282): 401:Authentication credentials (https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set valid conumer key/secret, access token/secret, and the system clock in in sync.
11-18 10:36:27.727: E/in Main.OAuthLogin(282): <?xml version="1.0" encoding="UTF-8"?>
11-18 10:36:27.727: E/in Main.OAuthLogin(282): <hash>
11-18 10:36:27.727: E/in Main.OAuthLogin(282):   <error>Desktop applications only support the oauth_callback value 'oob'</error>
11-18 10:36:27.727: E/in Main.OAuthLogin(282):   <request>/oauth/request_token</request>
11-18 10:36:27.727: E/in Main.OAuthLogin(282): </hash>

I believe i had not set up callback URL, but i did that as well to https://dev.twitter.com/pages/welcome-anywhere
in my app.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:01:32+00:00Added an answer on May 27, 2026 at 6:01 am

    My Bad… My Web server was down and i did not noticed it until 5 minutes ago. thanks for all suggestions. I have already done these things.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After sending the user to safari to authorize, i get sent to mobile.twitter.com as
We just finished implementing OAuth in our RoR application using the Twitter gem .
I have an application that integrates with Facebook using Oauth 2. I can authorize
I've developed a Facebook application using the Facebook C# SDK. Interestingly, whenever the user
I'm using the following code to authorize the application and then ask for permission
I want to develop an application for the business I work. We are using
Using Windows Forms I would like to have a small login screen the user
I'm using the facebook ios Sdk to connect my application with facebook. The login
To authorize a user on Facebook for my app, I am sending them to:
I am using FB.ui to authorize with application Facebook tab using simple: FB.init({ appId

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.