简体   繁体   English

Rails OAuth:无法从Microsoft Office 365 Rest API获取刷新令牌

[英]Rails OAuth: Can't get refresh token from microsoft office 365 rest api

I'm trying to figure out how to get the refresh token from an office365 user with omniauth. 我试图弄清楚如何使用omniauth从office365用户获取刷新令牌。

In my devise.rb file I have tried two different ways but to no avail: 在我的devise.rb文件中,我尝试了两种不同的方法,但无济于事:

config.omniauth :microsoft_office365, ENV['OFFICE365_APP_ID'], ENV['OFFICE365_SECRET'],
                  access_type: 'offline',
                  scope: 'https://outlook.office.com/calendars.read'

config.omniauth :microsoft_office365, ENV['OFFICE365_APP_ID'], ENV['OFFICE365_SECRET'],
                  scope: 'https://outlook.office.com/calendars.read, offline_access'

Am I doing something wrong here? 我在这里做错什么了吗?

It turns out the offline_access scope needn't be defined in devise.rb . 事实证明,无需在devise.rb定义offline_access范围。 All you have to do is add the scope in the Microsoft Application Registration Portal . 您所要做的就是在Microsoft 应用程序注册门户中添加范围。

For me, the microsoft_office365 config line in devise.rb now looks like this: 对我来说, devise.rb的microsoft_office365配置行现在看起来像这样:

  config.omniauth :microsoft_office365, ENV['OFFICE365_APP_ID'], ENV['OFFICE365_SECRET'],
                  scope: 'https://outlook.office.com/calendars.read'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Office 365返回的OAuth2令牌不包含preffered_username声明 - OAuth2 token returned from Office 365 doesn't contain a preffered_username claim 如何将Office 365 REST API集成到我的Ruby on Rails应用程序中? - How to integrate Office 365 REST API into my Ruby on Rails app? 无法在Rails应用中刷新Google API令牌 - Can't refresh Google API token in Rails app Rails 5,使用Microsoft帐户登录(Office 365) - Rails 5, login with Microsoft Account (Office 365) 使用Office 365 REST API搜索电子邮件 - Search emails using Office 365 REST API 如何正确注册和访问OAuth2的Office 365 Graph API(使用Ruby中的omniauth)? - How to properly register and access Office 365 Graph API for OAuth2 (using omniauth from Ruby)? 无法使用Devise,Rails 4从Omniauth身份验证策略中检索access_token,refresh_token - Can't retrieve access_token, refresh_token from Omniauth authentication strategy with Devise, Rails 4 如何使用Office365 REST API将OneDrive文件下载到Ruby变量中? - How can I download a OneDrive file with Office365 REST API into a Ruby variable? 来自 Outlook rest API 的 omniauth-office365 gem 权限错误 - omniauth-office365 gem permission error from Outlook rest API 无法使用Rails和OAuth gem获得我的access_token - Can't get my access_token using Rails and the OAuth gem
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM