Class: OmniAuth::Strategies::MicrosoftBusinessCentral
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::MicrosoftBusinessCentral
- Defined in:
- lib/omniauth/strategies/microsoft_business_central.rb
Constant Summary collapse
- SCOPE_PREFIX =
The Business Central API audience; bare scope names are qualified against it.
'https://api.businesscentral.dynamics.com/'- DEFAULT_SCOPE =
"#{SCOPE_PREFIX}user_impersonation offline_access"- OPENID_SCOPES =
OpenID Connect scopes that must be passed through unqualified.
%w[openid email profile offline_access].freeze
Instance Method Summary collapse
- #authorize_params ⇒ Object
-
#callback_url ⇒ Object
OmniAuth::Strategy#callback_url appends the callback request's own query string, and the Microsoft identity platform requires redirect_uri to match the registered value exactly.
- #client ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/omniauth/strategies/microsoft_business_central.rb', line 59 def super.tap do |params| # Any whitelisted authorize option can also be supplied per request: # /auth/microsoft_business_central?login_hint=user@example.com [:authorize_options].each do |key| value = request.params[key.to_s] params[key] = value unless value.nil? || value == '' end params[:scope] = normalize_scope(params[:scope] || DEFAULT_SCOPE) end end |
#callback_url ⇒ Object
OmniAuth::Strategy#callback_url appends the callback request's own query
string, and the Microsoft identity platform requires redirect_uri to match
the registered value exactly. omniauth 2's callback_path already carries
SCRIPT_NAME, so mount prefixes must not be added again.
76 77 78 |
# File 'lib/omniauth/strategies/microsoft_business_central.rb', line 76 def callback_url [:callback_url] || (full_host + callback_path) end |
#client ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/omniauth/strategies/microsoft_business_central.rb', line 51 def client = deep_symbolize(.) tenant = .tenant_id || 'common' [:authorize_url] ||= "#{tenant}/oauth2/v2.0/authorize" [:token_url] ||= "#{tenant}/oauth2/v2.0/token" ::OAuth2::Client.new(.client_id, .client_secret, ) end |