2016-06-16 18 views
0

私はこの公式のチュートリアルに続いてRailsアプリにOutlook REST APIを実装しました:https://dev.outlook.com/restapi/tutorial/ruby ところで、それは更新する必要があります。 Outlookは今認証コントローラでは、ユーザーの電子メールを取得するために、より多くの権限('profile')が必要です。Outlook REST APIの有効期限

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

をとにかく、私は電子メールを保存し、認証後にトークンが、そのトークンは非常に短命されています。ユーザーの認証を永続的に保存する方法が必要です。私が提案したようなものを実行して、電子メールを取得したい場合は 応答は次のとおりです。

... 
    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="[email protected]*", 
     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 

私は永久的なトークンを保存するために、このコードを調整するにはどうすればよいですか?

答えて

0

OK < StackOverflowでいくつかの回答が見つかりました。私は通常私の投稿を削除しますが、これを必要とするかもしれないRails開発者のために、私の質問への答えはSCOPES = [ 'openid', 'profile', 'offline_access', 'https://outlook.office.com/mail.read' ]

に単に ' offline_access'を追加するだけです
関連する問題