require 'omniauth/strategies/oauth2' MAIN_DOMAIN = Rails.env.development? ? 'http://8protons.dev' : 'https://8protons.com' API_DOMAIN = Rails.env.development? ? 'http://api8p.com' : 'https://api8p.com' 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: MAIN_DOMAIN, token_url: "#{API_DOMAIN}/oauth2/tokens", #authorize_url: '/oauth/auth' } uid { raw_info['id'] } info do { name: raw_info['fields']['display_name'], email: raw_info['fields']['email'], nickname: raw_info['fields']['username'] #:gravatar_hash => raw_info['fields']['gravatar_hash'] # and anything else you want to return to your API consumers } end extra do { 'raw_info' => raw_info } end def raw_info @raw_info ||= access_token.get("#{API_DOMAIN}/base/me").parsed end end # Protons end end