Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Ruby Readmill oAuth methods
get '/auth/readmill' do
redirect "{settings.readmill_client_id}&redirect_uri=#{settings.readmill_redirect}&scope=non-expiring"
get '/callback/readmill' do
token_params = {
:grant_type => 'authorization_code',
:client_id => settings.readmill_client_id,
:client_secret => settings.readmill_client_secret,
:redirect_uri => settings.readmill_redirect,
:code => params[:code],
:scope => 'non-expiring'
resp = JSON.parse("", token_params).to_str) rescue nil
data = {
:user => fetch_and_parse("", resp['access_token'])
user = User.first_or_create({ :readmill_id => data[:user]['id'] }) = data[:user]['username']
user.access_token = resp['access_token']
@access_token = resp['access_token']!
erb :twitter

great gist, hinke!

If you are looking for a php example. see my gist here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment