Sha256: 0bef902e39bd4fd56c9b3c7ed4de84c5f90a83216f4532596524937a946a39df

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'omniauth-oauth2'
require 'multi_json'

module OmniAuth
  module Strategies
    class Mindvalley < OmniAuth::Strategies::OAuth2
      case Rails.env
      when 'production'
        option :client_options, {
          :site => 'http://accounts.mindvalley.com',
          :authorize_url => 'http://accounts.mindvalley.com/oauth/authorize',
          :token_url => 'http://accounts.mindvalley.com/oauth/token'
        }
      else
        option :client_options, {
          :site => 'http://accounts.mindvalley.com',
          :authorize_url => 'http://accounts.mindvalley.com/oauth/authorize',
          :token_url => 'http://accounts.mindvalley.com/oauth/token'
#          :site => 'http://0.0.0.0:3000',
#          :authorize_url => 'http://0.0.0.0:3000/oauth/authorize',
#          :token_url => 'http://0.0.0.0:3000/oauth/token'
        }
      end

      uid { raw_info['id'] }

      info do
        {
          'email' => raw_info["user"]['email'],
          'first_name' => raw_info["user"]["info"]['first_name']
        }
      end

      def raw_info
        @raw_info ||= MultiJson.decode(access_token.get('/me').body)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-mindvalley-0.0.3 lib/omniauth/strategies/mindvalley.rb