Sha256: 56a5a75e98e0435cdf0e6c47851c2a243ed0d3ec73903f9f8879fabc7ce8f580

Contents?: true

Size: 1008 Bytes

Versions: 2

Compression:

Stored size: 1008 Bytes

Contents

require "omniauth/fresh_account/version"
require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class FreshAccount < OmniAuth::Strategies::OAuth2
      # change the class name and the :name option to match your application name
      option :name, :fresh_account

      option :client_options, {
        :site => "http://localhost:5000",
        :authorize_url => "/oauth/authorize"
      }

      uid { raw_info["id"] }

      info do
        {
          :email => raw_info["email"],
          :name => raw_info["name"],
          :avatar_url => raw_info["avatar_url"]
          # and anything else you want to return to your API consumers
        }
      end

      extra do
        skip_info? ? {} : { :raw_info => raw_info }
      end

      def raw_info
        @raw_info ||= access_token.get('/api/v1/me.json').parsed
      end

      # https://github.com/intridea/omniauth-oauth2/issues/81
      def callback_url
        full_host + script_name + callback_path
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth_fresh_account-0.2.6 lib/omniauth/fresh_account.rb
omniauth_fresh_account-0.2.5 lib/omniauth/fresh_account.rb