Coder Social home page Coder Social logo

dropbox-invite's Introduction

dropbox-invite

Gem Version Code Climate

UPDATE

Dropbox has recently changed their authentication process to prevent non-humans from logging in. Unfortunately for this library we haven't been able to break this restriction just yet.

Therefore, this library is useless at the moment.

Introduction

This gem allows you to invite other users to a shared folder in Dropbox. It's known that Dropbox API doesn't allow this operation, however it's a requirement in some scenarios.

To achieve this functionality and due to the lack of implementation in the official API, the library relies on rest-client and nokogiri to perform the action through the web interface.

Scope

This gem is meant to provide a missing functionality, not to build another API implementation. Ideally you'd use this library in combination with some actual implementation of the Dropbox API.

I recommend dropbox-api just because I've included integration for it. If Dropbox::API is found the existing classes will be extended to allow you invite people to your folders. This is shown in the examples below.

Disclaimer

This gem depends 100% on the parsing of the HTML from Dropbox web pages, therefore a change in their layouts might result in a broken library. Please, keep this in mind if you're planning to use this in a production environment.

Another drawback of using the web interface is of course the speed.

How to use

Using it with dropbox-api (recommended)

First, you'll need to set up dropbox-api as explained in the [gem's README] (https://github.com/futuresimple/dropbox-api):

Dropbox::API::Config.app_key    = YOUR_APP_KEY
Dropbox::API::Config.app_secret = YOUR_APP_SECRET
Dropbox::API::Config.mode       = "dropbox" # This is a requirement

At this point you're able to instantiate a Dropbox::API::Client object either through web-based authorization or rake-based. So far, nothing new.

Additionally you'll need to set up the web login credentials as part of the API settings to enable the initialization of a web client when it's required.

Dropbox::API::Config.web_session = Dropbox::WebClient::Session.new(
  :email => "[email protected]",
  :password => "yourPassw0rd"
)

Note that the web authentication won't happen until you actually need it, i.e. when the invite method is invoked.

Now, assuming that you've got a Dropbox::API::Dir object called some_dir, you'd be able to perform this:

response = some_dir.invite("[email protected]")
# => #<Dropbox::WebClient::ResponseParser ... >
response.error?
# => false
response.response_data
# => {"success_msg"=>"Created shared folder 'folder x'", "sf_info"=>{"mount_point"=>"/folder x", "user_id"=>372486289, "extra_count"=>0, "sort_rank"=>nil, "encoded_sort_key"=>["NkhCMjROBloBDAEMAA=="], "other_emails"=>[], "other_names"=>[], "modified_pretty"=>"just now", "href"=>"/home/folder%20x", "modified_ts"=>1420051083, "filename"=>"folder x", "target_ns_id"=>791334450, "icon"=>"folder_user"}}

Additionally you can check who's included in the dir through members:

some_dir.members
# => ["[email protected]", "[email protected]"]

Using it on its own (standalone, not recommended)

session = Dropbox::WebClient::Session.new(
  :email => "[email protected]",
  :password => "yourPassw0rd"
)
session.invite("/folder path", ["[email protected]"])
# => #<Dropbox::WebClient::ResponseParser ... >

To do

Would be nice to:

  • Record tests in HTTP instead of HTTPS so they'd be readable. To do so we'll need a proxy.
  • Implement other functions (share permissions, etc).
  • Improve error handling.
  • Add setting to disable lazy authentication.

Problems?

Please report them in issues

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.