为看似有效的`/ messages`调用获取`invalid_token`错误

时间:2016-09-09 18:44:46

标签: azure authentication outlook-restapi

我在invalid_tokenGET时遇到奇怪的https://outlook.office.com/api/v2.0/me/messages错误,即使我提供的access_token是新鲜有效的。

#<Faraday::Response:0x007f842a55d9c0 @on_complete_callbacks=[], @env=#<Faraday::Env @method=:get @body="" @url=#<URI::HTTPS https://outlook.office.com/api/v2.0/me/messages> @request=#<Faraday::RequestOptions (empty)> @request_headers={"User-Agent"=>"Faraday v0.9.2", "Authorization"=>"Bearer XXXXX_my_access_code_goes_hereXXXXX"} @ssl=#<Faraday::SSLOptions verify=true> @response=#<Faraday::Response:0x007f842a55d9c0 ...> @response_headers={"content-length"=>"0", "server"=>"Microsoft-IIS/8.5", "set-cookie"=>"exchangecookie=da79bef43acf4d1aa5f0bb00988f6629; expires=Sat, 09-Sep-2017 18:34:51 GMT; path=/; HttpOnly", "www-authenticate"=>"Bearer client_id=\"my_client_id\", 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=\"\",Basic Realm=\"\"", "request-id"=>"28ed7077-b92c-470a-b062-0f5f2a54d74a", "x-calculatedfetarget"=>"DM3PR12CU001.internal.outlook.com", "x-backendhttpstatus"=>"401, 401", "x-feproxyinfo"=>"DM3PR12CA0039.NAMPRD12.PROD.OUTLOOK.COM", "x-calculatedbetarget"=>"DM2PR12MB0315.namprd12.prod.outlook.com", "x-ms-diagnostics"=>"2000010;reason=\"ErrorCode: 'PP_E_RPS_CERT_NOT_FOUND'. Message: 'Certificate cannot be found. Certificate required for the operation cannot be found.%0d%0a Internal error: spRPSTicket->ProcessToken failed.'\";error_category=\"invalid_msa_ticket\"", "x-diaginfo"=>"DM2PR12MB0315", "x-beserver"=>"DM2PR12MB0315", "x-feserver"=>"DM3PR12CA0039, BY1PR13CA0015", "x-powered-by"=>"ASP.NET", "x-msedge-ref"=>"Ref A: A8A103D34AD84EC089A59EFDA0AF5385 Ref B: 740314A1C3A73205090D30CCB559AAA0 Ref C: Fri Sep  9 11:34:51 2016 PST", "date"=>"Fri, 09 Sep 2016 18:34:50 GMT", "connection"=>"close"} @status=401>>

1 个答案:

答案 0 :(得分:2)

我找到了答案。显然,范围https://graph.microsoft.com/mail.read(我要求的)与https://outlook.office.com/mail.read不同。一旦我切换到使用范围内的outlook.office.com,我的API调用也会起作用。