Beispiel #1
0
        /// <summary>
        /// Sets a UserLogin (Token and Secret) for the current client
        /// </summary>
        /// <param name="userLogin"></param>
        public void SetUserToken(UserLogin userLogin)
        {
            UserLogin = userLogin;

            if (_oauthHandler != null) //not sure when this would ever be null
            {
                _oauthHandler.UserToken = userLogin.Token;
                _oauthHandler.UserSecret = userLogin.Secret;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets an authorize url for the current UserLogin (after getting a Request Token)
        /// </summary>
        /// <param name="userLogin"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public string BuildAuthorizeUrl(UserLogin userLogin, string callback = null)
        {
            if (userLogin == null)
            {
                throw new ArgumentNullException("userLogin");
            }

            //Go 1-Liner!
            return string.Format("https://www.dropbox.com/1/oauth/authorize?oauth_token={0}{1}", userLogin.Token,
                (string.IsNullOrEmpty(callback) ? string.Empty : "&oauth_callback=" + callback));
        }
Beispiel #3
0
        /// <summary>
        /// Reads the auth response parameters and creates a UserLogin object from it
        /// </summary>
        /// <param name="urlParams"></param>
        /// <returns></returns>
        private UserLogin GetUserLoginFromParams(string urlParams)
        {
            var userLogin = new UserLogin();

            var parameters = urlParams.Split('&');

            foreach (var parameter in parameters)
            {
                if (parameter.Split('=')[0] == "oauth_token_secret")
                {
                    userLogin.Secret = parameter.Split('=')[1];
                }
                else if (parameter.Split('=')[0] == "oauth_token")
                {
                    userLogin.Token = parameter.Split('=')[1];
                }
            }

            return userLogin;
        }