Skip to content

Instantly share code, notes, and snippets.

@semanticart
Created September 11, 2011 16:32
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 semanticart/1209793 to your computer and use it in GitHub Desktop.
Save semanticart/1209793 to your computer and use it in GitHub Desktop.
example sinatra app
require 'rubygems'
require 'httparty'
require 'sinatra'
require 'ruby-debug'
require 'baby_tooth'
configure do
enable :sessions
BabyTooth.configure do |config|
config.client_id = 'XXXXXXXX',
config.client_secret = 'XXXXXXXXXX',
config.authorization_url = 'https://runkeeper.com/apps/authorize',
config.access_token_url = 'https://runkeeper.com/apps/token',
config.redirect_uri = "http://localhost:4567/after"
config.site = 'http://api.runkeeper.com'
end
end
get "/" do
# do the oauth dance if we aren't logged in
if session[:token].nil?
redirect BabyTooth.authorize_url
else
user = BabyTooth::User.new(session[:token])
user.body
end
end
# throw the oauth token into our session
get "/after" do
session[:token] = BabyTooth.get_token(params[:code])
redirect "/"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment