Sha256: c8ad47d6d09828c7b037e3b276204a8475b22fb94f573f41f3a9a5305f8fd01a

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'omniauth/strategies/oauth2'
require 'omniauth/infinum/configuration'

module OmniAuth
	module Strategies
		class Infinum < OmniAuth::Strategies::OAuth2

			#############
			### Setup ###
			#############

			option :client_options, {
				site: "http://accounts.infinum.co",
				authorize_url: "/auth/infinum/authorize",
				access_token_url: "/auth/infinum/access_token"
			}

			uid { raw_info['id'] }

			info do
				{
					email: raw_info['email']
				}
			end # info

			extra do
				{
					first_name: raw_info['extra']['first_name'],
					last_name: raw_info['extra']['last_name'],
					email: raw_info['extra']['email'],
					avatar_url: raw_info['extra']['avatar_url'],
					slack_username: raw_info['extra']['slack_username']
				}
			end # extra

			##############
			### Phases ###
			##############

			def request_phase
				super
			end # request_phase

			def callback_phase
				super
			end # callback_phase

			###############
			### Helpers ###
			###############

			def raw_info
				@raw_info ||= access_token.get("/auth/infinum/user.json?oauth_token=#{access_token.token}").parsed
			end # raw_info

		end # Facebook
	end # Strategies
end # OmniAuth

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-infinum-0.10.1 lib/omniauth/strategies/infinum.rb