Microsoft Graph OAuth2 Strategy for OmniAuth. Can be used to authenticate with Office365 or other MS services, and get a token for the Microsoft Graph Api, formerly the Office365 Unified Api.
Add this line to your application's Gemfile:
gem 'omniauth-microsoft_graph'
And then execute:
$ bundle
Or install it yourself as:
$ gem install omniauth-microsoft_graph
Register a new app in the Azure Portal / App registrations to get the AZURE_APPLICATION_CLIENT_ID
and AZURE_APPLICATION_CLIENT_SECRET
below.
Rails.application.config.middleware.use OmniAuth::Builder do
provider :microsoft_graph, ENV['AZURE_APPLICATION_CLIENT_ID'], ENV['AZURE_APPLICATION_CLIENT_SECRET']
end
Just add {login_hint: "[email protected]"} to your url generation to form:
/auth/microsoft_graph?login_hint=email@example.com
This version requires OmniAuth v2. If you are using Rails, you will need to include or upgrade omniauth-rails_csrf_protection
. If you upgrade and get an error in your logs complaining about "authenticity error" or similiar, make sure to do bundle update omniauth-rails_csrf_protection
- Fork it ( https://github.com/synth/omniauth-microsoft_graph/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request