Created
September 11, 2011 16:32
-
-
Save semanticart/1209793 to your computer and use it in GitHub Desktop.
example sinatra app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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