【问题标题】:omniauth-office365 gem permission error from Outlook rest API来自 Outlook REST API 的omniauth-office365 gem 权限错误
【发布时间】:2020-03-16 18:51:29
【问题描述】:

Hello All 将基本的 office 365 集成到 Rails 应用程序的联系人。我已经使用omniauth-google-oauth2 和google-api-client 与google 建立了联系。我正在关注https://docs.microsoft.com/en-us/outlook/rest/ruby-tutorial 进行应用程序设置,并像以前一样使用omniauth-office365 策略。看来我的所有设置都正确,但是当我进行身份验证时出现以下错误:

我根据文档进行了设置,但我不知道我错过了什么..

此时的基本用法只是进行身份验证,我在omniauth.rb中添加了以下代码:

`

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

我在 routes.rb 中添加了一条路线:

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

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

在我的控制器中我添加了:

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

在视图中我添加了一个链接:

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

我用谷歌做了上面的方法,效果很好,当然我添加了更多的代码来从 API 中获取我需要的东西,但是获得了预先的身份验证。如果我单击该链接,我会从 office365 获得预期的登录/身份验证屏幕,但它会返回图像中显示的权限错误,即使它被设置为能够访问所有帐户。

【问题讨论】:

标签: ruby-on-rails ruby oauth office365api


【解决方案1】:

问题出在 gem 策略 omniauth-office365 上。我关注https://docs.microsoft.com/en-us/graph/tutorials/ruby?tutorial-step=3 并添加了该策略并能够进行身份验证..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-09
    • 1970-01-01
    • 2018-02-15
    相关资源
    最近更新 更多