コード例 #1
0
        public AuthModule(ITwitter twitter) : base("/auth")
        {
            Get["/twitter"] = _ =>
            {
                string callback = TwitterCallback;
                if (Request.Query.returnUrl != null)
                {
                    callback += "?returnUrl=" + ((string)Request.Query.returnUrl).UrlEncode();
                }
                return(new RedirectResponse(twitter.GetAuthorizeUri(ConsumerKey, ConsumerSecret, new Uri(callback)).ToString()));
            };

            Get["/twitter_callback"] = _ => this.LoginAndRedirect((Guid)twitter.GetUser(ConsumerKey, ConsumerSecret,
                                                                                        Request.Query.oauth_token,
                                                                                        Request.Query.oauth_verifier).
                                                                  UserGuid, DateTime.Today.AddDays(1), Request.Query.returnUrl as string ?? "/");
        }
コード例 #2
0
ファイル: AuthModule.cs プロジェクト: markrendle/NancyTwitter
        public AuthModule(ITwitter twitter)
            : base("/auth")
        {
            Get["/twitter"] = _ =>
                                  {
                                      string callback = TwitterCallback;
                                      if (Request.Query.returnUrl != null)
                                      {
                                          callback += "?returnUrl=" + ((string) Request.Query.returnUrl).UrlEncode();
                                      }
                                      return new RedirectResponse(twitter.GetAuthorizeUri(ConsumerKey, ConsumerSecret, new Uri(callback)).ToString());
                                  };

            Get["/twitter_callback"] = _ => this.LoginAndRedirect((Guid) twitter.GetUser(ConsumerKey, ConsumerSecret,
                                                                                         Request.Query.oauth_token,
                                                                                         Request.Query.oauth_verifier).
                                                                             UserGuid, DateTime.Today.AddDays(1), Request.Query.returnUrl as string ?? "/");
        }