Created
January 13, 2013 11:08
-
-
Save anonymous/4523556 to your computer and use it in GitHub Desktop.
Code sample for testing out Sinatra's issue # 596
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 '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