示例#1
0
        /// <summary>
        /// Asynchronously performs authorization for Silverlight apps
        /// </summary>
        /// <param name="authorizationCompleteCallback">Action you provide for when authorization completes.</param>
        public void BeginAuthorize(Action <TwitterAsyncResponse <UserIdentifier> > authorizationCompleteCallback)
        {
            if (IsAuthorized)
            {
                return;
            }

            var request = new Request(OAuthAccessTokenUrl);

            var xauthCredentials = Credentials as XAuthCredentials;
            var postData         = new Dictionary <string, string>();

            postData.Add("x_auth_username", xauthCredentials.UserName);
            postData.Add("x_auth_password", xauthCredentials.Password);
            postData.Add("x_auth_mode", "client_auth");

            OAuthTwitter.PostAccessTokenAsync(
                request,
                postData,
                resp =>
            {
                Credentials.OAuthToken  = OAuthTwitter.OAuthToken;
                Credentials.AccessToken = OAuthTwitter.OAuthTokenSecret;
                UserIdentifier user     = resp.State;
                if (user != null)
                {
                    Credentials.ScreenName = user.ScreenName;
                    Credentials.UserId     = user.UserID;
                }

                authorizationCompleteCallback(resp);
            });
        }
示例#2
0
        /// <summary>
        /// Asynchronously performs authorization for Silverlight apps
        /// </summary>
        /// <param name="authorizationCompleteCallback">Action you provide for when authorization completes.</param>
        public void BeginAuthorize(Action <TwitterAsyncResponse <UserIdentifier> > authorizationCompleteCallback)
        {
            if (IsAuthorized)
            {
                return;
            }

            var xauthCredentials = Credentials as XAuthCredentials;

            string postData =
                "x_auth_username="******"&" +
                "x_auth_password="******"&" +
                "x_auth_mode=client_auth";

            string url = OAuthAccessTokenUrl + "?" + postData;

            OAuthTwitter.PostAccessTokenAsync(new Uri(url), postData, authorizationCompleteCallback);
        }