简体   繁体   English

Outlook REST API到期

[英]Outlook REST API expiration

I implemented the outlook REST api on my Rails app following this official tutorial: https://dev.outlook.com/restapi/tutorial/ruby By the way, it needs to be updated. 我遵循以下官方教程在Rails应用程序上实现了Outlook REST API: https : //dev.outlook.com/restapi/tutorial/ruby顺便说一下,需要对其进行更新。 Outlook now requires more permissions ( 'profile' ) to get the email of the user in the auth controller: Outlook现在需要更多权限( 'profile' )才能在auth控制器中获取用户的电子邮件:

SCOPES = [ 'openid', 'profile', 'https://outlook.office.com/mail.read' ]

Anyhow, I am storing the email and token after authenticating, but that token is very short lived. 无论如何,我将在身份验证后存储电子邮件和令牌,但是该令牌的寿命很短。 I need a way to permanently store authentication for the user. 我需要一种永久存储用户身份验证的方法。 When I run things as suggested and want to get the emails the response is: 当我按照建议运行并想要接收电子邮件时,响应为:

...
  response_headers: !ruby/hash-with-ivars:Faraday::Utils::Headers
    elements:
      content-length: '0'
      server: Microsoft-IIS/8.5
      set-cookie: exchangecookie=afaeef5a8a6747aab24dad1ddb97a8fb; expires=Fri, 16-Jun-2017
        00:07:54 GMT; path=/; HttpOnly
      www-authenticate: Bearer client_id="00000002-0000-0ff1-ce00-000000000000", trusted_issuers="00000001-0000-0000-c000-000000000000@*",
        token_types="app_asserted_user_v1 service_asserted_app_v1", authorization_uri="https://login.windows.net/common/oauth2/authorize",
        error="invalid_token",Basic Realm="",Basic Realm=""
      request-id: c59488ab-62b5-4a9f-a3f5-43bda739c9ab
      x-calculatedbetarget: BLUPR07MB260.namprd07.prod.outlook.com
      x-backendhttpstatus: '401'
      x-ms-diagnostics: '2000010;reason="ErrorCode: ''PP_E_RPS_REASON_TIMEWINDOW_EXPIRED''.
        Message: ''Failed the Validate call, reason: Time window expired.%0d%0a''";error_category="invalid_msa_ticket"'
      x-diaginfo: BLUPR07MB260
      x-beserver: BLUPR07MB260
      x-powered-by: ASP.NET
      x-feserver: BN3PR16CA0057
      x-msedge-ref: 'Ref A: 3E2E02429DE244F7A738A7BE6CF9E06B Ref B: CAA6321D024D5B725BA8FFE7DAC85411
        Ref C: Wed Jun 15 17:07:54 2016 PST'
      date: Thu, 16 Jun 2016 00:07:54 GMT
      connection: close
    ivars:
      :@names:
        content-length: content-length
        server: server
        set-cookie: set-cookie
        www-authenticate: www-authenticate
        request-id: request-id
        x-calculatedbetarget: x-calculatedbetarget
        x-backendhttpstatus: x-backendhttpstatus
        x-ms-diagnostics: x-ms-diagnostics
        x-diaginfo: x-diaginfo
        x-beserver: x-beserver
        x-powered-by: x-powered-by
        x-feserver: x-feserver
        x-msedge-ref: x-msedge-ref
        date: date
        connection: connection
  status: 401

How do I adjust this code to store a permanent token? 如何调整此代码以存储永久令牌?

OK< I found a few answers on StackOverflow for different stacks. 好的<我在StackOverflow上为不同的堆栈找到了一些答案。 I would normally delete my post, but for Rails developer who may need this, the answer to my questions is simply adding ' offline_access ' to SCOPES = [ 'openid', 'profile', 'offline_access', 'https://outlook.office.com/mail.read' ] 我通常会删除我的帖子,但是对于可能需要此内容的Rails开发人员,我的问题的答案是在SCOPES = [ 'openid', 'profile', 'offline_access', 'https://outlook.office.com/mail.read' ]添加' offline_access ' SCOPES = [ 'openid', 'profile', 'offline_access', 'https://outlook.office.com/mail.read' ]

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

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