Sha256: 8748fc3fe6671105ceacaa89914d419f4227036449a84acc4f867659327ca13b

Contents?: true

Size: 927 Bytes

Versions: 2

Compression:

Stored size: 927 Bytes

Contents

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

class Kuda
  def name
    "kudakwashe"
  end
end

class OmniAuth::Strategies::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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth_fresh_account-0.2.8 lib/omniauth/strategies/fresh_account.rb
omniauth_fresh_account-0.2.7 lib/omniauth/strategies/fresh_account.rb