Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Created September 24, 2012 03:20
Show Gist options
  • Select an option

  • Save zeroeth/3774039 to your computer and use it in GitHub Desktop.

Select an option

Save zeroeth/3774039 to your computer and use it in GitHub Desktop.
weeeee
require 'omniauth-oauth'
module OmniAuth
module Strategies
class Ravelry < OmniAuth::Strategies::OAuth
# Give your strategy a name.
option :name, "ravelry"
# This is where you pass the options you would pass when
# initializing your consumer from the OAuth gem.
option :client_options, {:site => "https://www.ravelry.com/"}
# These are called after authentication has succeeded. If
# possible, you should try to set the UID without making
# additional calls (if the user id is returned with the token
# or as a URI parameter). This may not be possible with all
# providers.
#
# ravelry puts request.params['username'] but thats all
uid{ raw_info['user']['id'] }
info do
{
:uid => raw_info['user']['id'],
:player_name => raw_info['user']['username'],
:email => nil
}
end
extra do
{
'raw_info' => raw_info
}
end
def raw_info
@raw_info ||= MultiJson.decode(access_token.get('https://api.ravelry.com/current_user.json').body)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment