cirandas.net

ref: master

plugins/oauth_client/lib/omniauth/strategies/noosfero_oauth2.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'omniauth/strategies/oauth2'

module OmniAuth
  module Strategies
    class NoosferoOauth2 < OmniAuth::Strategies::OAuth2
      option :name, :noosfero_oauth2
      option :client_options, {
        :authorize_url => '/oauth_provider/oauth/authorize',
        :token_url     => '/oauth_provider/oauth/token'
      }

      uid { raw_info["id"] }

      info do
        {
          :email => raw_info["email"]
        }
      end

      def raw_info
        #FIXME access the noosfero api (coming soon)
        @raw_info ||= access_token.get('/plugin/oauth_provider/public/me').parsed
      end
    end
  end
end