Sha256: 4cace51103ec58ef4d336cbd2bb382bbce765db575373787e529fe2290765f2c

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class MsOffice365 < OmniAuth::Strategies::OAuth2
      option :name, :office365

      option :client_options, {
          site:          'https://login.microsoftonline.com',
          authorize_url: '/common/oauth2/v2.0/authorize',
          token_url:     '/common/oauth2/v2.0/token'
      }

      def authorize_params
        options.authorize_params[:scope] = 'offline_access openid User.Read Contacts.Read'
        super
      end

      uid { raw_info['id'] }

      info do
        {
          'email' => raw_info["userPrincipalName"],
          'name' => [raw_info["givenName"], raw_info["surname"]].join(' '),
          'nickname' => raw_info["displayName"]
        }
      end

      extra do
        {
          'raw_info' => raw_info
        }
      end

      def raw_info
        @raw_info ||= access_token.get('https://graph.microsoft.com/v1.0/me').parsed
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-ms-office365-1.0.1 lib/omniauth/strategies/ms_office365.rb
omniauth-ms-office365-1.0.0 lib/omniauth/strategies/ms_office365.rb