Sha256: d818cdb9026946800247939d757813802bf592a026bf2be379cb00041e99a81d

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class OnShapeDev < OmniAuth::Strategies::OAuth2
      # Give your strategy a name.
      option :name, 'onshape_dev'

      # This is where you pass the options you would pass when
      # initializing your consumer from the OAuth gem.
      option :client_options, {
        :site => 'https://partner.dev.onshape.com/api',
        :authorize_url => 'https://partner.dev.onshape.com/oauth/authorize',
        :token_url => 'https://partner.dev.onshape.com/oauth/token'
      }

      # option :scope, 'r_basicprofile r_emailaddress'
      # option :fields, ['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-url', 'public-profile-url']

      # These are called after authentication has succeeded. If
      # possible, you should try to set the UID without making
      # additional calls (if the user id is returned with the token
      # or as a URI parameter). This may not be possible with all
      # providers.
      uid { raw_info['id'] }

      info do
        {
          :name => raw_info['name'],
          :email => raw_info['email']
        }
      end

      extra do
        { 'raw_info' => raw_info }
      end

      def raw_info
        @raw_info ||= access_token.get("users/sessioninfo").parsed
      end

    end
  end
end

OmniAuth.config.add_camelization 'onshape_dev', 'OnShapeDev'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-onshape-oauth2-0.1.3 lib/omniauth/strategies/onshape.rb