static object GetInitiator(
            NancyContext context,
            IConfiguration configuration)
        {
            context.Ensure("context");
            configuration.Ensure("configuration");

            var returnUrl = context.Request.Query["return-url"].Value as string;
            if (!String.IsNullOrEmpty(returnUrl))
                context.SetReturnUrl(returnUrl);

            var callbackUri = fn.MakeAbsoluteUri(Paths.TwitterAuthReceiver());

            var oAuthRequest = OAuthRequest.ForRequestToken(
                configuration.TwitterAuthConsumerKey,
                configuration.TwitterAuthConsumerSecret,
                callbackUri.ToString());
            oAuthRequest.RequestUrl = Constants.TwitterAuth.RequestTokenUrl;

            var response = fn.SendGet(
                new Uri(oAuthRequest.RequestUrl),
                addHeader => addHeader("Authorization", oAuthRequest.GetAuthorizationHeader()));

            var @params = fn.ParseQueryString(response);

            var token = @params[Constants.TwitterAuth.OAuthTokenParamName];

            if (String.IsNullOrEmpty(token))
                throw new InvalidOperationException(Strings.OAuthTokenMissing());

            context.WriteSession(Constants.TwitterAuth.SessionKey, token);

            return context.Redirect(string.Format(
                CultureInfo.InvariantCulture,
                Constants.TwitterAuth.AuthenticatehUrlFormat,
                token));
        }
        static string GetOrCreateUser(
            NancyContext context,
            string twitterUserId)
        {
            // we're going to store the Twitter user identifier
            var authId = twitterUserId;

            // if we didn't get a Twitter user identifier, we can't proceed
            if (String.IsNullOrWhiteSpace(authId))
                throw new InvalidOperationException("The Twitter user ID must not be empty.");

            // store the signed-in user in session, so we have the information later when they sign up
            context.WriteSession(Constants.AuthTypeSessionKey, Constants.TwitterAuth.AuthType);
            context.WriteSession(Constants.AuthIdSessionKey, authId);

            return authId;
        }