Skip to content

Instantly share code, notes, and snippets.

@malachaifrazier
Created July 13, 2012 04:03
Show Gist options
  • Save malachaifrazier/3102656 to your computer and use it in GitHub Desktop.
Save malachaifrazier/3102656 to your computer and use it in GitHub Desktop.
require "rubygems"
require "httparty"
require "sinatra"
require "omniauth-singly"
SINGLY_API_BASE = "https://api.singly.com"
enable :sessions
use OmniAuth::Builder do
provider :singly, 'SINGLY_ID', 'SINGLY_SECRET'
end
get "/" do
if session[:access_token]
@profiles = HTTParty.get(profiles_url, {
:query => {:access_token => session[:access_token]}
}).parsed_response
end
erb :index
end
get "/auth/singly/callback" do
auth = request.env["omniauth.auth"]
session[:access_token] = auth.credentials.token
redirect "/"
end
get "/logout" do
session.clear
redirect "/"
end
def profiles_url
"#{SINGLY_API_BASE}/profiles"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment