A user gets redirected here after hitting Twitter and authorizing your app to use their data.

    This is the view that stores the tokens you want
    for querying data. Pay attention to this.
171939
def thanks(request, redirect_url=settings.LOGIN_REDIRECT_URL):
    
    # Now that we've got the magic tokens back from Twitter, we need to exchange
    # for permanent ones and store them...
    oauth_token = request.session['request_token']['oauth_token']
    oauth_token_secret = request.session['request_token']['oauth_token_secret']
    twitter = Twython(settings.TWITTER_KEY, settings.TWITTER_SECRET,
                      oauth_token, oauth_token_secret)

    # Retrieve the tokens we want...
    authorized_tokens = twitter.get_authorized_tokens(request.GET['oauth_verifier'])

    # If they already exist, grab them, login and redirect to a page displaying stuff.
    try:
        user = User.objects.get(username=authorized_tokens['screen_name'])
    except User.DoesNotExist:
        # We mock a creation here; no email, password is just the token, etc.
        user = User.objects.create_user(authorized_tokens['screen_name'], "fjdsfn@jfndjfn.com", authorized_tokens['oauth_token_secret'])
        profile = TwitterProfile()
        profile.user = user
        profile.oauth_token = authorized_tokens['oauth_token']
        profile.oauth_secret = authorized_tokens['oauth_token_secret']
        profile.save()

    user = authenticate(
        username=authorized_tokens['screen_name'],
        password=authorized_tokens['oauth_token_secret']
    )
    login(request, user)
    redirect_url = request.session.get('next_url', redirect_url)

    HttpResponseRedirect(redirect_url)
357648
def logged_in(self):
        
        if "oauth-access-token" not in self.store:
            return False

        response = self.request("/api/whoami", allow_redirects=False)

        # It should response with a redirect to our profile if it's logged in
        if response.status_code != 302:
            return False

        # the location should be the profile we have
        if response.headers["location"] != self.me.links["self"]:
            return False

        return True
1366182
function load_followers_priodically() {
    try{

	twimap.followersAsync(last_check, function(result) {
		if(typeof result != "undefined" && result.length >=1){
			//save it in our variable
			_followers_list = result;
            last_check = now();
            msg_followers_thanks();
		}


	},function (err){

        //  I command you to stay silent
        reset_values();
    });

    }catch(e){
    //still...
        reset_values();
        console.log(e);
    }
}
1282227
function() {
              // Sets pending redirect status before redirect to
              // accountchooser.com.
              firebaseui.auth.storage.setPendingRedirectStatus(app.getAppId());
              firebaseui.auth.acClient.trySelectAccount(
                  function(isAvailable) {
                    // Removes the pending redirect status if does not get
                    // redirected to accountchooser.com.
                    firebaseui.auth.storage.removePendingRedirectStatus(
                        app.getAppId());
                    // On empty response, post accountchooser.com result (either
                    // empty or unavailable).
                    var AccountChooserResult =
                        firebaseui.auth.widget.Config.AccountChooserResult;
                    firebaseui.auth.widget.handler.common.accountChooserResult(
                        app,
                        isAvailable ?
                          AccountChooserResult.EMPTY :
                          AccountChooserResult.UNAVAILABLE,
                        function() {
                          // If not available, go to the sign-in screen and no
                          // UI shown callback.
                          firebaseui.auth.widget.handler.handle(
                              firebaseui.auth.widget.HandlerName.SIGN_IN,
                              app,
                              container,
                              opt_email);
                        });
                  },
                  firebaseui.auth.storage.getRememberedAccounts(app.getAppId()),
                  app.getConfig().getWidgetUrl(
                      firebaseui.auth.widget.Config.WidgetMode.SELECT));
            }
595916
function (data) {
			//console.log("login_data");
			//console.log(data);
			if (data === null) {
				var err = new Error("ACCOUNT_NOT_FOUND " + account);
				err.name = "login Error";
				err.code = 1;
				return UTIL.safeCall(onDone, err);
			}

			// by default we assume authentication fails and return token does not exist
			var result = false;
			var token = undefined;		
			
			// determine to check password or check token
			if (by_account)
				result = (l_encryptPass(password) === data.password);
			else
				// NOTE: check if the requester of the token was the same as the one logined previously
				result = (data.pass_tokens.hasOwnProperty(password));
				
			// check login is success or fail
			if (result === true) {
				l_addLogin(account, data, conn);
				
				// generate unique token and store it if requested
				if (requester) {
					var l_createTokenDone = function (l_createToken_err, token) {
						if (l_createToken_err) {
							var err = new Error("ACCOUNT_LOGIN_TOKENSTORE_FAIL: " + account);
							err.name = "login Error";
							err.code = 1;
							UTIL.safeCall(onDone, err);
						}
						else {
							UTIL.safeCall(onDone, null, {code: 0, msg: 'ACCOUNT_LOGIN_SUCCESS: ' + account, uid: data.uid, token: token, data: data});
						}
					};
					l_createToken(data.uid, requester, l_createTokenDone);
				}
				else {
					return UTIL.safeCall(onDone, null, {code: 0, msg: 'ACCOUNT_LOGIN_SUCCESS: ' + account, data: data});
				}
			}
			else {
				var err = new Error("ACCOUNT_LOGIN_PASSFAIL: " + account);
				err.name = "login Error";
				err.code = 1;
				return UTIL.safeCall(onDone, err);
			}
		}
1299087
def post_tweet_intent_handler(request):
    
    tweet = request.get_slot_value("Tweet")
    tweet = tweet if tweet else ""    
    if tweet:
        user_state = twitter_cache.get_user_state(request.access_token())
        def action():
            return post_tweet(request.access_token(), tweet)

        message = "I am ready to post the tweet, {} ,\n Please say yes to confirm or stop to cancel .".format(tweet)
        user_state['pending_action'] = {"action" : action,
                                        "description" : message} 
        return r.create_response(message=message, end_session=False)
    else:
        # No tweet could be disambiguated
        message = " ".join(
            [
                "I'm sorry, I couldn't understand what you wanted to tweet .",
                "Please prepend the message with either post or tweet ."
            ]
        )
        return alexa.create_response(message=message, end_session=False)
253884
function _getUserSocialDetails(){
    return BB
        .bind(this)
        .then(function() {
            return pinterest
                .query()
                .get('me/?fields=id,first_name,last_name,url,username,image&access_token=' + this.params.access_token)
                .request();
        })
        .then(function(res){
            this.socialUserInfo = res[1].data;
        });
}
1125430
def get_sns_access_token
      path = '/sns/gettoken'
      response = fire_request path, {appid: app_id, appsecret: app_secret}, method: :get
      response[:access_token]
    end
240534
function Query(server, query, options, token) {
  this.server = server;
  this.query = query;
  // Used to track the presence of r.args (workaround)
  this.originalQuery = util.deepCopy(query);
  this.options = {};
  this.context = {};
  this.frames = [];
  this.nowValue = ReqlDate.now();
  this.complete = false;
  this.token = token;

}
519283
def confirm_email_view(self, token):
        
        # Verify token
        data_items = self.token_manager.verify_token(
            token,
            self.USER_CONFIRM_EMAIL_EXPIRATION)

        # Retrieve user, user_email by ID
        user = None
        user_email = None
        if data_items:
            user, user_email = self.db_manager.get_user_and_user_email_by_id(data_items[0])

        if not user or not user_email:
            flash(_('Invalid confirmation token.'), 'error')
            return redirect(url_for('user.login'))

        # Set UserEmail.email_confirmed_at
        user_email.email_confirmed_at=datetime.utcnow()
        self.db_manager.save_user_and_user_email(user, user_email)
        self.db_manager.commit()

        # Send confirmed_email signal
        signals.user_confirmed_email.send(current_app._get_current_object(), user=user)

        # Flash a system message
        flash(_('Your email has been confirmed.'), 'success')

        # Auto-login after confirm or redirect to login page
        safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_CONFIRM_ENDPOINT)
        if self.USER_AUTO_LOGIN_AFTER_CONFIRM:
            return self._do_login_user(user, safe_next_url)  # auto-login
        else:
            return redirect(url_for('user.login') + '?next=' + quote(safe_next_url))
440021
@Override
    public void getOAuthRequestTokenAsync() {
        getDispatcher().invokeLater(new AsyncTask(OAUTH_REQUEST_TOKEN, listeners) {
            @Override
            public void invoke(List<TwitterListener> listeners) throws TwitterException {
                RequestToken token = twitter.getOAuthRequestToken();
                for (TwitterListener listener : listeners) {
                    try {
                        listener.gotOAuthRequestToken(token);
                    } catch (Exception e) {
                        logger.warn("Exception at getOAuthRequestTokenAsync", e);
                    }
                }
            }
        });
    }
905537
def help(*args)
      puts "#{NameColor}console-tweet#{DefaultColor} by John Crepezzi <john.crepezzi@gmail.com>"
      puts 'http://github.com/seejohnrun/console-tweet'
      puts
      puts "#{CommandColor}twitter#{DefaultColor} View your timeline, since last view"
      puts "#{CommandColor}twitter setup#{DefaultColor} Setup your account"
      puts "#{CommandColor}twitter status#{DefaultColor} Get your most recent status" 
      puts "#{CommandColor}twitter tweet \"Hello World\"#{DefaultColor} Send out a tweet"
      puts "#{CommandColor}twitter show [username]#{DefaultColor} Show the timeline for a user"
      puts "#{CommandColor}twitter replies#{DefaultColor} Get the most recent @replies and mentions" 
    end
651299
public function actionLogin() {

		$this->twitterService->requestToken();

		$authToken = Yii::$app->session->get( 'tw_oauth_token' );

		$this->redirect( "https://api.twitter.com/oauth/authorize?oauth_token=$authToken" );
	}
67327
public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            long cursor = -1;
            IDs ids;
            System.out.println("Showing outgoing pending follow request(s).");
            do {
                ids = twitter.getOutgoingFriendships(cursor);
                for (long id : ids.getIDs()) {
                    System.out.println(id);
                }
            } while ((cursor = ids.getNextCursor()) != 0);
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to get outgoing friendships: " + te.getMessage());
            System.exit(-1);
        }
    }
202145
function getUsers(){
    console.log('getUsers called');
    grout.Users.get().then(function(app){
      console.log('apps list loaded:', app);
      document.getElementById("output").innerHTML = JSON.stringify(app);
    }, function(err){
      console.error('Error getting users:', err);
    });
  }
1126805
function () {
    // Get stored auth data.
    var stored = this.storage.get();

    // If nothing stored, proceed with new authorization
    if (!stored) {
      this.log('No auth data stored, starting authorization from scratch...');
      return this.auth.authorize();
    }

    // Otherwise, set the auth data on the Request object so that it can be used for requests
    this.log('Auth data stored, checking validity...');
    this._auth = utils.unserialize(stored);

    // Use the saved auth data to check if we're already authorized. If not, it will clear the stored
    // data, then proceed with new authorization.
    return this.auth.isAuth()
      .then(function(result) {
        if (result === false)
          return this.auth.authorize();
      }.bind(this));
  }
104710
def authorized(self):
        
        if self.redirect_url:
            next_url = self.redirect_url
        elif self.redirect_to:
            next_url = url_for(self.redirect_to)
        else:
            next_url = "/"

        try:
            self.session.parse_authorization_response(request.url)
        except TokenMissing as err:
            message = err.args[0]
            response = getattr(err, "response", None)
            log.warning("OAuth 1 access token error: %s", message)
            oauth_error.send(self, message=message, response=response)
            return redirect(next_url)

        try:
            token = self.session.fetch_access_token(
                self.access_token_url, should_load_token=False
            )
        except ValueError as err:
            # can't proceed with OAuth, have to just redirect to next_url
            message = err.args[0]
            response = getattr(err, "response", None)
            log.warning("OAuth 1 access token error: %s", message)
            oauth_error.send(self, message=message, response=response)
            return redirect(next_url)

        results = oauth_authorized.send(self, token=token) or []
        set_token = True
        for func, ret in results:
            if isinstance(ret, (Response, current_app.response_class)):
                return ret
            if ret == False:
                set_token = False

        if set_token:
            self.token = token
        return redirect(next_url)