GithubHelp home page GithubHelp logo

terrorizer1980 / dropnet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dropnet/dropnet

0.0 0.0 0.0 20.21 MB

Client Library for the Dropbox API

Home Page: http://dropnet.github.io/dropnet.html

License: Apache License 2.0

C# 100.00%

dropnet's Introduction

Note: Development of DropNet has stopped!

DropNet is no longer under development and the current version of the library does not work with Dropbox API v2. I recommend moving to the official Dropbox .net SDK - https://github.com/dropbox/dropbox-sdk-dotnet


.NET Client library for the Dropbox API

Build status

Full documentation here: http://dropnet.github.io/dropnet.html

How do I use it?

The Client:

To use DropNet you need an instance of the DropNetClient class, this class does everything for DropNet. This class takes the API Key and API Secret (These must be obtained from Dropbox to access the API).

    _client = new DropNetClient("API KEY", "API SECRET");
Login/Tokens:

Dropbox now requires a web authentication to get a usable token/secret, so this is a 3 step process.

Step 1. Get Request Token - This step gets an oauth token from dropbox (NOTE: the token must pass the other steps before it can be used)

    // Sync
    _client.GetToken();
    
    // Async
    _client.GetTokenAsync((userLogin) =>
        {
            //Dont really need to do anything with userLogin, DropNet takes care of it for now
        },
        (error) =>
        {
            //Handle error
        });

Step 2. Authorize App with Dropbox - This step involves sending the user to a login page on the dropbox site and having them authenticate there. The DropNet client has a function to return the url for you but the rest must be handled in app, this function also takes a callback url for redirecting the user to after they have logged in. (NOTE: The token still cant be used yet.)

    var url = _client.BuildAuthorizeUrl();
    //Use the url in a browser so the user can login

Open a browser with the url returned by BuildAuthorizeUrl - After we have the authorize url we need to direct the user there (use some sort of browser here depending on the platform) and navigate the user to the url. This will prompt them to login and authorize your app with the API.

Step 3. Get an Access Token from the Request Token - This is the last stage of the process, converting the oauth request token into a usable dropbox API token. This function will use the clients stored Request Token but this can be overloaded if you need to specify a token to use.

    // Sync
    var accessToken = _client.GetAccessToken(); //Store this token for "remember me" function
 
    // Async
    _client.GetAccessTokenAsync((accessToken) =>
        {
            //Store this token for "remember me" function
        },
        (error) =>
        {
            //Handle error
        });

Best Practices: Dropbox's Developer page states several times in bold red font that applications should not store a users Dropbox password and to help enforce this DropNet allows you to manually set a users Token and Secret on the client.

    _client = new DropNetClient("API KEY", "API SECRET", "USER TOKEN", "USER SECRET");
    // OR
    _client = new DropNetClient("API KEY", "API SECRET");
    _client.UserLogin = new UserLogin { Token = "USER TOKEN", Secret = "USER SECRET" };

Questions? http://stackoverflow.com/questions/tagged/dropnet

dropnet's People

Contributors

austhomp avatar briceattouchtech avatar chafey avatar crackalak avatar daviddesloovere avatar derigel23 avatar dipth avatar dkarzon avatar drfriedparts avatar grantcolley avatar jbct avatar jhoerr avatar jmacentee avatar mchristopher avatar mercan01 avatar michaelpereira avatar misterfoo avatar myownclone avatar nicwise avatar partyz0ne avatar petemill avatar philchuang avatar possan avatar runeborg avatar staticcat avatar tgnm avatar victorbello avatar zeroid avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.