當前位置: 首頁>>代碼示例>>C#>>正文


C# TweetSharp.OAuthRequestToken類代碼示例

本文整理匯總了C#中TweetSharp.OAuthRequestToken的典型用法代碼示例。如果您正苦於以下問題:C# OAuthRequestToken類的具體用法?C# OAuthRequestToken怎麽用?C# OAuthRequestToken使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OAuthRequestToken類屬於TweetSharp命名空間,在下文中一共展示了OAuthRequestToken類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ProcessAuthoriztion

        public LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
        {
            var twitterService = new TwitterService(KeyStorage.Get("twitterKey"), KeyStorage.Get("twitterSecret"));

            if (String.IsNullOrEmpty(context.Request["oauth_token"]) ||
                String.IsNullOrEmpty(context.Request["oauth_verifier"]))
            {
                var requestToken = twitterService.GetRequestToken(context.Request.Url.AbsoluteUri);

                var uri = twitterService.GetAuthorizationUri(requestToken);

                context.Response.Redirect(uri.ToString(), true);
            }
            else
            {
                var requestToken = new OAuthRequestToken { Token = context.Request["oauth_token"] };
                var accessToken = twitterService.GetAccessToken(requestToken, context.Request["oauth_verifier"]);
                twitterService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);

                var user = twitterService.VerifyCredentials(new VerifyCredentialsOptions());

                return ProfileFromTwitter(user);
            }

            return new LoginProfile();

        }
開發者ID:haoasqui,項目名稱:ONLYOFFICE-Server,代碼行數:27,代碼來源:TwitterLoginProvider.cs

示例2: TwitterCreateOrUpdateAccountIfNeeded

        Models.User IOAuthSignInClient.OAuthCallback(HttpRequestBase Request)
        {
            if (string.IsNullOrEmpty(Request["denied"]))
            {
                var requestToken = new OAuthRequestToken { Token = Request["oauth_token"] };

                // Step 3 - Exchange the Request Token for an Access Token
                OAuthAccessToken accessToken = twitterService.GetAccessToken(requestToken, Request["oauth_verifier"]);
                // Step 4 - User authenticates using the Access Token
                twitterService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);

                TwitterUser user = twitterService.VerifyCredentials();
                if (null != user)
                {
                    // We are adding an account to this user
                    User masterUser = null;
                    if (!string.IsNullOrEmpty(Request["Id"]))
                    {
                        masterUser = database.Users.FirstOrDefault(u => u.UniqueId == Request["Id"]);
                    }
                    var appUser = TwitterCreateOrUpdateAccountIfNeeded(accessToken, user, masterUser);
                    return appUser;
                }
                else
                {
                    //TODO: we should probably throw some kind of authentication error here
                    return null;
                }
            }
            else
            {
                //TODO: Should we really return null here? This request was denied.
                return null;
            }
        }
開發者ID:sethwebster,項目名稱:TweetHarbor,代碼行數:35,代碼來源:TwitterOAuthClient.cs

示例3: GetResponseHtml

        public string GetResponseHtml(IDictionary<string, string> parameters, Uri signinUri)
        {
            var requestToken = new OAuthRequestToken {Token = parameters["oauth_token"]};

            // Exchange the Request Token for an Access Token
            var service = new TwitterService(Settings.TwitterConsumerKey, Settings.TwitterConsumerSecret);
            OAuthAccessToken accessToken = service.GetAccessToken(requestToken, parameters["oauth_verifier"]);

            // Claim values
            string name = accessToken.ScreenName;
            string nameIdentifier = string.Format("https://twitter.com/account/redirect_by_id?id={0}", accessToken.UserId);
            string token = accessToken.Token;
            string tokenSecret = accessToken.TokenSecret;

            string wtRealm = _configurationProvider.Get(Settings.TwitterWtRealm);
            string wReply = _configurationProvider.Get(Settings.TwitterWReply);

            var requestMessage = new SignInRequestMessage(signinUri, wtRealm, wReply);

            // Add claims
            var identity = new ClaimsIdentity(AuthenticationTypes.Federation);
            identity.AddClaim(new Claim(ClaimTypes.Name, name));
            identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, nameIdentifier));
            identity.AddClaim(new Claim(TwitterClaims.TwitterToken, token));
            identity.AddClaim(new Claim(TwitterClaims.TwitterTokenSecret, tokenSecret));

            var principal = new ClaimsPrincipal(identity);

            // Serialize response message
            SignInResponseMessage responseMessage = FederatedPassiveSecurityTokenServiceOperations.ProcessSignInRequest(requestMessage, principal, this);
            responseMessage.Context = parameters["context"];

            return responseMessage.WriteFormPost();
        }
開發者ID:jorik041,項目名稱:MVCSTS,代碼行數:34,代碼來源:TwitterSecurityTokenService.cs

示例4: ReturnFromTwitter

        // This URL is registered as the application's callback at http://dev.twitter.com
        public ActionResult ReturnFromTwitter(string oauth_token, string oauth_verifier)
        {
            var requestToken = new OAuthRequestToken { Token = oauth_token };

            // Step 3 - Exchange the Request Token for an Access Token
            string _consumerKey = System.Configuration.ConfigurationManager.AppSettings["consumerKeyLogin"];
            string _consumerSecret = System.Configuration.ConfigurationManager.AppSettings["consumerSecretLogin"];
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);
            OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

            string TwitterToken = accessToken.Token;
            string TwitterToeknSecret = accessToken.TokenSecret;
            Session[Sessionvars.TwitterRequestToken] = TwitterToken;  //You can save this token in your database for pulling user's data in future. this will be save every time while getting permission
            Session[Sessionvars.TwitterRequestTokenSecert] = TwitterToeknSecret; //You can save this token in your database for pulling user's data in future. this will be save every time while getting permission
            ViewBag.TwitterToken = accessToken.Token;

            // Step 4 - User authenticates using the Access Token

            //service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            //TwitterUser user = service.VerifyCredentials();
            //var status = user.Status;
            //ViewBag.status = status;
            //ViewBag.UserName = user.Name;
            //ViewBag.location = user.Location;
            //ViewBag.count = user.FollowersCount;

            //TwitterDirectMessage Ds = service.SendDirectMessage(user.Id, "hi this test messages");
            //service.SendTweet("hi this is test from me at live");
            //service.SendTweet("msg", user.Id);
            //ViewBag.Userid = service.BeginFollowUserNotifications(user.Id);

            return RedirectToAction("Invite");
        }
開發者ID:emiprotech,項目名稱:loginwithtwitter,代碼行數:34,代碼來源:HomeController.cs

示例5: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            //get parameters
            string oauth_token = context.Request.Params["oauth_token"];
            string oauth_verifier = context.Request.Params["oauth_verifier"];

            var requestToken = new OAuthRequestToken { Token = oauth_token };

            // Step 3 - Exchange the Request Token for an Access Token
            Global.TwitterService = new TwitterService(Global.TwitterConsumerKey, Global.TwitterConsumerSecret);
            OAuthAccessToken accessToken = Global.TwitterService.GetAccessToken(requestToken, oauth_verifier);

            // Step 4 - User authenticates using the Access Token
            Global.TwitterService.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            TwitterUser user = Global.TwitterService.VerifyCredentials(new VerifyCredentialsOptions());

            //var sessionProps = (SessionProperties) context.Session["sessionProps"];
            //sessionProps.TwitterAccessToken = accessToken.Token;
            //sessionProps.TwitterAccessTokenSecret = accessToken.TokenSecret;

            Parameters.Instance.TwitterAccessToken = accessToken.Token;
            Parameters.Instance.TwitterAccessTokenSecret = accessToken.TokenSecret;

            //service.SendTweet(new SendTweetOptions(){Status = "Testing twitter function. Carrry on"});
            context.Response.Redirect("../AdminMain.aspx");
        }
開發者ID:supersalad,項目名稱:Interntipset,代碼行數:26,代碼來源:TwAuthCallback.ashx.cs

示例6: AuthorizeCallback

 public static string AuthorizeCallback(string oauthToken, string oauthVerifier)
 {
     var requestToken = new OAuthRequestToken {Token = oauthToken};
     var service = new TwitterService(ConsumerToken.ConsumerKey,
         ConsumerToken.ConsumerSecret);
     var accessToken = service.GetAccessToken(requestToken, oauthVerifier);
     return accessToken.Token;
 }
開發者ID:Stelmashenko-A,項目名稱:CourseWork,代碼行數:8,代碼來源:TwitterOauth.cs

示例7: AuthorizeCallback

        // This URL is registered as the application's callback at http://dev.twitter.com
        public ActionResult AuthorizeCallback(string oauth_token, string oauth_verifier)
        {
            var requestToken = new OAuthRequestToken { Token = oauth_token, OAuthCallbackConfirmed = true };

            TwitterService service = new TwitterService(ConfigurationManager.AppSettings["TwitterConsumerKey"], ConfigurationManager.AppSettings["TwitterConsumerSecret"]);
            OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier.ToString());

            Session["Twitter.AccessToken"] = accessToken.Token;
            Session["Twitter.AccessTokenSecret"] = accessToken.TokenSecret;

            return RedirectToAction("Index", "Home");
        }
開發者ID:ryanmcdonnell,項目名稱:twinklelinks,代碼行數:13,代碼來源:AuthController.cs

示例8: GetTokens

 public static void GetTokens(string oautToken, string verifier, out string token, out string tokenSecret,
     out string screenName, out long id)
 {
     var requestToken = new OAuthRequestToken {Token = oautToken};
     var service = new TwitterService(ConsumerToken.ConsumerKey,
         ConsumerToken.ConsumerSecret);
     var accessToken = service.GetAccessToken(requestToken, verifier);
     token = accessToken.Token;
     tokenSecret = accessToken.TokenSecret;
     screenName = accessToken.ScreenName;
     id = accessToken.UserId;
 }
開發者ID:Stelmashenko-A,項目名稱:CourseWork,代碼行數:12,代碼來源:TwitterOauth.cs

示例9: Authenticate

        public bool Authenticate(OAuthRequestToken requestToken, string oauth_verifier, ref string Token, ref string tokenSecret)
        {
            OAuthAccessToken accessToken= twitter.GetAccessToken(requestToken, oauth_verifier);
            if (accessToken != null)
            {
                twitter.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);

                Token = accessToken.Token;
                tokenSecret = accessToken.TokenSecret;
                return true;
            }
            return false;
        }
開發者ID:msanj1,項目名稱:BOTF,代碼行數:13,代碼來源:TwitterApi.cs

示例10: LoginCallback

        public ActionResult LoginCallback(string returnUrl, string oauth_token, string oauth_verifier)
        {
            var requestToken = new OAuthRequestToken {Token = oauth_token};
            var service = new TwitterService(ConsumerKey, ConsumerSecret);
            var accessToken = service.GetAccessToken(requestToken, oauth_verifier);
            service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            var twitterUser = service.VerifyCredentials(new VerifyCredentialsOptions());

            var user = new User {Name = twitterUser.ScreenName, DisplayName = twitterUser.Name, ImageUrl = new Uri(twitterUser.ProfileImageUrl)};
            userRepository.Save(user);
            FormsAuthentication.SetAuthCookie(user.Name, false);
            return Redirect(returnUrl);
        }
開發者ID:RomanGorgol,項目名稱:nosql,代碼行數:13,代碼來源:AuthController.cs

示例11: BrowserLogin_Click

 private void BrowserLogin_Click(object sender, System.EventArgs e)
 {
     // ブラウザーを起動(OAuth認証)
     requestToken = service.GetRequestToken();
     Uri uri = service.GetAuthenticationUrl(requestToken);
     Process.Start(uri.ToString());
 }
開發者ID:kmkmkmk,項目名稱:KanKoreBrowser,代碼行數:7,代碼來源:TwitterLogin.cs

示例12: AuthTwitter1

        public void AuthTwitter1()
        {
            // Step 1 - Retrieve an OAuth Request Token
            requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            Process.Start(uri.ToString());
        }
開發者ID:dcmeier,項目名稱:fydp,代碼行數:9,代碼來源:SocialNetworkingService.cs

示例13: Authorize_Click

        private void Authorize_Click(object sender, EventArgs e)
        {
            SetupTwitterClient();

            requestToken = twitterService.GetRequestToken();
            var authUrl = twitterService.GetAuthorizationUri(requestToken);

            Process.Start(authUrl.ToString());
        }
開發者ID:RihanMeij,項目名稱:Bee,代碼行數:9,代碼來源:Form1.cs

示例14: InitializeNewSession

 private void InitializeNewSession()
 {
     _twitterClientInfo = new TwitterClientInfo();
     _twitterClientInfo.ConsumerKey = "2yeyhTAMl3Euzc2aXSlOA"; //TODO: get this value especially for adidas
     _twitterClientInfo.ConsumerSecret = "8yXVBamNBfd82hSbCbBNWPQvto0cjgqVjYuBbLXm0";
         //TODO: get this value especially for adidas
     _twitterService = new TwitterService(_twitterClientInfo);
     _requestToken = _twitterService.GetRequestToken();
 }
開發者ID:OurDemoGroup,項目名稱:Samples,代碼行數:9,代碼來源:MainWindow.xaml.cs

示例15: OnLoad

 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     _twitterService = new TwitterService(Constants.ConsumerKey,
         Constants.ConsumerSecret);
     _requestToken = _twitterService.GetRequestToken();
     //_applicationCredentials = CredentialsCreator.GenerateApplicationCredentials);
     _url = _twitterService.GetAuthorizationUri(_requestToken).ToString();
 }
開發者ID:crashracer,項目名稱:Sdl-Community,代碼行數:9,代碼來源:TwitterAccountSetup.cs


注:本文中的TweetSharp.OAuthRequestToken類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。