Sha256: d2cf5c01b154385a7251a2dd2a33c45f184201215c92b726e9d23b0362953469

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

# frozen_string_literal: true

module OmniAuth
  module Strategies
    class Forge < OmniAuth::Strategies::OAuth2
      option :name, 'forge'

      option(
        :client_options,
        {
          site: 'https://developer.api.autodesk.com',
          authorize_url: '/authentication/v1/authorize',
          token_url: '/authentication/v1/gettoken',
        }
      )

      option :callback_path, '/forge/callback'

      uid do
        raw_info['userId']
      end

      info do
        {
          user_name: raw_info['userName'],
          email: raw_info['emailId'],
          first_name: raw_info['firstName'],
          last_name: raw_info['lastName'],
        }
      end

      extra do
        {
          'raw_info' => raw_info,
        }
      end

      # Forge is expecting a callback_url without parameters
      def callback_url
        super.gsub(/\?.*$/, '')
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-forge-0.1.2 lib/omniauth/strategies/forge.rb
omniauth-forge-0.1.1 lib/omniauth/strategies/forge.rb