require 'omniauth/strategies/oauth2' module OmniAuth module Strategies # Authentication strategy for connecting with APIs constructed using # the [OAuth 2.0 Specification](http://tools.ietf.org/html/draft-ietf-oauth-v2-10). # You must generally register your application with the provider and # utilize an application id and secret in order to authenticate using # OAuth 2.0. class Protons < OmniAuth::Strategies::OAuth2 # change the class name and the :name option to match your application name option :name, :protons option :client_options, { :site => Rails.env.development? ? "http://8protons.dev" : "https://8protons.com", :authorize_url => "/oauth/authorize" } uid { raw_info["id"] } info do { :name => raw_info["display_name"], :email => raw_info["email"], :nickname => raw_info["username"] # and anything else you want to return to your API consumers } end def raw_info @raw_info ||= access_token.get('/api/users/me.json').parsed end end # Protons end end