Sha256: ba64dabd7e3da862195579926f05b102d06478088cecf8a6a8e9d6b90f42a5c0

Contents?: true

Size: 972 Bytes

Versions: 9

Compression:

Stored size: 972 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class SomeSite < OmniAuth::Strategies::OAuth2
      # Give your strategy a name.
      option :name, 'some_site'

      # This is where you pass the options you would pass when
      # initializing your consumer from the OAuth gem.
      option :client_options, site: 'https://api.somesite.com'

      # These are called after authentication has succeeded. If
      # possible, you should try to set the UID without making
      # additional calls (if the user id is returned with the token
      # or as a URI parameter). This may not be possible with all
      # providers.
      uid { raw_info['id'] }

      info do
        {
          :name => raw_info['name'],
          :email => raw_info['email']
        }
      end

      extra do
        {
          'raw_info' => raw_info
        }
      end

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

Version data entries

9 entries across 8 versions & 2 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/hashie-3.5.7/spec/integration/omniauth-oauth2/some_site.rb
hashie-3.5.7 spec/integration/omniauth-oauth2/some_site.rb
hashie-3.5.6 spec/integration/omniauth-oauth2/some_site.rb
tdiary-5.0.5 vendor/bundle/gems/hashie-3.5.5/spec/integration/omniauth-oauth2/some_site.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/hashie-3.5.5/spec/integration/omniauth-oauth2/some_site.rb
tdiary-5.0.4 vendor/bundle/gems/hashie-3.5.5/spec/integration/omniauth-oauth2/some_site.rb
hashie-3.5.5 spec/integration/omniauth-oauth2/some_site.rb
hashie-3.5.4 spec/integration/omniauth-oauth2/some_site.rb
hashie-3.5.3 spec/integration/omniauth-oauth2/some_site.rb