Skip to content

Instantly share code, notes, and snippets.

@chrishomer
Created September 28, 2013 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrishomer/6747910 to your computer and use it in GitHub Desktop.
Save chrishomer/6747910 to your computer and use it in GitHub Desktop.
# 1. Create a new record (account email is optional)
@db_session = MyDropboxSession.create({app_key: MyDropboxSession::APP_KEY,
app_secret: MyDropboxSession::APP_SECRET,
account_email: "a_dropbox_email@example.com"})
# 2. Get the authorization url and visit it in your browser and then authorize the Application
@db_session.authorization_url
# 3. After authorizing in the browser, complete the authorization
# - This gets the access token, serializes the session and saves it in the database
@db_session.complete_authorization
# 4. Use the client to your heart's content
@db_session.client.metadata "/"
# Next time:
# 1. Recovering the session is automatic when you load the active record
@db_session = TupDropboxSession.authorized.where(account_email: "a_dropbox_email@example.com").last
# 2. Use the client
@db_session.client.metadata "/"
# It's that easy!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment