Skip to content

Instantly share code, notes, and snippets.

@codebrane
Created August 3, 2013 09:56
Show Gist options
  • Save codebrane/6145919 to your computer and use it in GitHub Desktop.
Save codebrane/6145919 to your computer and use it in GitHub Desktop.
Setup Dropbox access from Ruby
require 'dropbox_sdk'
APP_KEY = 'YOUR_APP_KEY'
APP_SECRET = 'YOUR_APP_SECRET'
flow = DropboxOAuth2FlowNoRedirect.new(APP_KEY, APP_SECRET)
authorize_url = flow.start()
puts '1. Go to: ' + authorize_url
puts '2. Click "Allow" (you might have to log in first)'
puts '3. Copy the authorization code'
print 'Enter the authorization code here: '
code = gets.strip
access_token, user_id = flow.finish(code)
File.open('access_token', 'w') { |file|
file.write(access_token)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment