Ejemplo n.º 1
0
        /// <summary>
        /// Asynchronously finishes the authorization process
        /// </summary>
        /// <param name="callback">Callback Url that Twitter has added parameters to</param>
        /// <param name="authorizationCompleteCallback">Action you provide for when authorization completes.</param>
        public void CompleteAuthorize(Uri callback, Action <TwitterAsyncResponse <UserIdentifier> > authorizationCompleteCallback)
        {
            if (IsAuthorized)
            {
                return;
            }

            const int QueryPart = 1;

            string[] callbackParts = callback.OriginalString.Split('?');

            if (callbackParts.Length == 2)
            {
                string oauthToken = OAuthTwitter.GetUrlParamValue(callbackParts[QueryPart], "oauth_token");
                Credentials.OAuthToken  = oauthToken;
                OAuthTwitter.OAuthToken = oauthToken;

                // we have to split on # because Twitter appends #PageName at the end of the url,
                // which identifies the Silverlight page to navigate to, but is not part of the verifier
                string verifier =
                    OAuthTwitter
                    .GetUrlParamValue(callbackParts[QueryPart], "oauth_verifier")
                    .Split('#')[0];

                if (verifier != null)
                {
                    OAuthTwitter.GetAccessTokenAsync(verifier, new Uri(OAuthAccessTokenUrl), null, authorizationCompleteCallback);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Asynchronously finishes the authorization process
        /// </summary>
        /// <param name="pin">Set this to the 7-digit PIN that Twitter provides after the user authorizes your application</param>
        /// <param name="authorizationCompleteCallback">Action you provide for when authorization completes.</param>
        public void CompleteAuthorize(string pin, Action <TwitterAsyncResponse <UserIdentifier> > authorizationCompleteCallback)
        {
            if (IsAuthorized)
            {
                return;
            }

            if (pin == null)
            {
                throw new ArgumentNullException("pin", "pin is required");
            }

            OAuthTwitter.GetAccessTokenAsync(
                pin, new Uri(OAuthAccessTokenUrl), "oob", AuthAccessType.NoChange,
                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);
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Asynchronously finishes the authorization process
        /// </summary>
        /// <param name="pin">Set this to the 7-digit PIN that Twitter provides after the user authorizes your application</param>
        /// <param name="authorizationCompleteCallback">Action you provide for when authorization completes.</param>
        public void CompleteAuthorize(string pin, Action <TwitterAsyncResponse <UserIdentifier> > authorizationCompleteCallback)
        {
            if (IsAuthorized)
            {
                return;
            }

            if (pin == null)
            {
                throw new ArgumentNullException("pin", "pin is required");
            }

            OAuthTwitter.GetAccessTokenAsync(pin, new Uri(OAuthAccessTokenUrl), "oob", authorizationCompleteCallback);
        }