Sha256: 1417a6ae33d6740b3908e71c84338c9cbc132ea8cf3e1b27a62c5a30c90188e3

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 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['user']['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

3 entries across 3 versions & 1 rubygems

Version Path
omniauth-mindvalley-0.0.6 lib/omniauth/strategies/mindvalley.rb
omniauth-mindvalley-0.0.5 lib/omniauth/strategies/mindvalley.rb
omniauth-mindvalley-0.0.4 lib/omniauth/strategies/mindvalley.rb