简体   繁体   中英

omniauth-office365 gem permission error from Outlook rest API

Hello All implementing basic office 365 integration to contacts from a rails application. I have already connected with google using omniauth-google-oauth2 and google-api-client. I am following https://docs.microsoft.com/en-us/outlook/rest/ruby-tutorial for app setup and am using the strategy omniauth-office365 as I did previously. It appears I have all setup right but when I authenticate I get the following error: 在此处输入图像描述

I have my settings in accordance to the docs, I dont know what I am missing..

The basic usage at this moment is just to authenticate which I have added the code below to omniauth.rb:

`

Rails.application.config.middleware.use OmniAuth::Builder do
     provider :office365, '$myid', '$mykey',
           {:scope => 'mail.read, User.read, profile,openid'}
end

I added a route to my routes.rb:

  get 'auth/:provider/callback', to: 'contacts#contact_integrations'

  get 'auth/failure', to: redirect('/')

In my controller I added:

  def contact_integrations
    access_token = request.env["omniauth.auth"]
  end

In a view I added a link to:

<%= link_to 'Outlook', "/auth/office365" %>

I did the above method with google and it worked fine, of course I added more code to get what I needed from the API but the upfront authentication was obtained. If I click the link I get the expected login/authenticate screens from office365, but it returns the permissions error shown in the image even though it is set to be able to access all accounts.

Issue was with the gem strategy omniauth-office365. I followed https://docs.microsoft.com/en-us/graph/tutorials/ruby?tutorial-step=3 and added that strategy and was able to authenticate..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM