Login and saving token

Except providing DropBoxy with DropBox key and secret, you should sign in user with valid DropBox account.

There is possible two variants of how you can prepare instance of DropBoxyEngine to work with DropBox.

1. Signing In to account using email and password
That is a naturaly way, you've just using method called Login and sending user email and password to this method. Don't be afrad - DropBoxy never stores email and password of the user, and it is highly reccomended for your applicaiton to not store such data too. To Login to DropBox using email and password plese use next code:

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //creating callback function. Will occur after login completed
            Action<UserInfo> callback = LoginCompleted;

            DropBoxy.DropBoxyEngine engine = new DropBoxy.DropBoxyEngine();
            engine.ApiKey = "yourapikey";
            engine.ApiSecret = "yourapisecret";

            engine.Login("john.doe@somecompany.com", "password", callback);
        }
        
        /// <summary>
        ///  Login completed 
        /// </summary>
        void LoginCompleted(DropBoxy.Models.UserInfo userInfo)
        {}

As you can see callback function is created because we are forced to use Async operations during development for WP7 platform. Model UserInfo has two properties: Token and Secret - this is values which you can use instead of email and password for authentication at DropBox system. Signing In is only one method to receive these values, so you should ask your user to enter password at least once, then you can store user token and secret somewhere in your application data.

To use UserInfo tokens for authorizing user in system , please use next code:
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            DropBoxy.DropBoxyEngine engine = new DropBoxy.DropBoxyEngine();
            engine.ApiKey = "yourapikey";
            engine.ApiSecret = "yourapisecret";
            engine.SetToken("tokenReceived", "secretReceived");
        }

Last edited Jan 15, 2011 at 12:48 PM by dimko1, version 1

Comments

No comments yet.