Sha256: ada151a4a3ecee65ff182b070f81b7356953ac329c4c99d594b19f245aacf39f

Contents?: true

Size: 964 Bytes

Versions: 3

Compression:

Stored size: 964 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 { raw_info['userId'] }

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

      extra { { 'raw_info' => raw_info } }

      # 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

3 entries across 3 versions & 1 rubygems

Version Path
omniauth-forge-0.2.1.1 lib/omniauth/strategies/forge.rb
omniauth-forge-0.2.1 lib/omniauth/strategies/forge.rb
omniauth-forge-0.2.0 lib/omniauth/strategies/forge.rb