Skip to content

Instantly share code, notes, and snippets.

Created January 13, 2013 11:08
Show Gist options
  • Save anonymous/4523556 to your computer and use it in GitHub Desktop.
Save anonymous/4523556 to your computer and use it in GitHub Desktop.
Code sample for testing out Sinatra's issue # 596
require 'sinatra'
require 'soundcloud'
class App < Sinatra::Base
def client_id
ENV['CLIENT_ID']
end
def client_secret
ENV['CLIENT_SECRET']
end
set :port, 9292
get '/login' do
client = Soundcloud.new(:client_id => client_id,
:client_secret => client_secret,
:redirect_uri => "http://localhost:9292/done")
redirect client.authorize_url()
end
get '/done' do
params
end
run!
end
# Soundcloud embeds the Access code of the user who has logged in the query params. It can be obtained
# using params[:code] inside the '/done/ url. This code needs to be sent in all future requests to access
# the user's functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment