Sha256: 7321a026d87b6d307ded28d33d27c10d42f4079ebdde1b791b2c230b626a5a0a

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 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["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.2 lib/omniauth/strategies/mindvalley.rb