如何将 Outlook REST API 与 'Office 365 Deutschland' 一起使用
How to use Outlook REST API with 'Office 365 Deutschland'
我正在使用 Microsoft Office 365 REST API 从 Office 365 和 Outlook.com 帐户读取日历项目。
效果不错。
现在,我需要从 Office 365 Deutschland 个帐户中读取相同的内容。那是行不通的。
我已经发现以下内容:
使用另一个端点登录
国际:https://login.microsoftonline.com/common/oauth2/v2.0/authorize
德国:https://login.microsoftonline.de/common/oauth2/authorize
为 REST 使用另一个端点 API
国际:https://outlook.office.com/api/v2.0/me/calendar/events
德国:https://outlook.office.de/api/v2.0/me/calendar/events
需要另一个ClientID/ClientSecret
国际:https://apps.dev.microsoft.com
德国:https://portal.microsoftazure.de
使用不同的 oauth2 范围
国际:offline_access https://outlook.office.com/Calendars.Read
德国:offline_access openid https://outlook.office.de/Calendars.Read
有了这些,我就可以获得 OAuth2 访问令牌。但是当我打电话给
https://outlook.office.de/api/v2.0/me
或
https://outlook.office.de/api/v2.0/me/calendarview?startDateTime=2018-01-01T01:00:00&endDateTime=2018-10-31T23:00:00
使用该令牌,我只收到以下错误:
Request Headers:
cache-control:"no-cache"
postman-token:"b765d2d1-9ffc-4016-8216-38678af4f245"
authorization:"Bearer AQA*** snip for security***gAA"
user-agent:"PostmanRuntime/7.1.5"
accept:"*/*"
host:"outlook.office.de"
cookie:"ClientId=DFDA316304974E36A43D11CF7BB6D8A3; OIDC=1; OpenIdConnect.nonce.v3.y7kDkk7dHuGjDZ9PZ_xiLj0CjfuLbQt629j5MuTcNp8=636667242602536754.c00ff4a6-e523-4dff-b1ce-24d1d024ce67"
accept-encoding:"gzip, deflate"
Response Headers:
server:"Microsoft-IIS/10.0"
request-id:"e59f5e5e-0980-4914-9087-064270bdd233"
x-calculatedfetarget:"LEJPR01CU002.internal.outlook.com"
x-backendhttpstatus:
0:"401"
1:"401"
x-feproxyinfo:"LEJPR01CA0057.DEUPRD01.PROD.OUTLOOK.DE"
x-calculatedbetarget:"FRXPR01MB0456.DEUPRD01.PROD.OUTLOOK.DE"
x-rum-validated:"1"
x-ms-diagnostics:"2000010;reason="ErrorCode: 'PP_E_RPS_INVALIDCONFIG'. Message: 'Invalid configuration. Check event log for actions.%0d%0a Internal error: Config directory does not exist; config directory must exist and be an absolute path:C:\Program Files\Microsoft Passport RPS\LiveIdConfig.'";error_category="invalid_msa_ticket""
x-besku:"Gen8"
x-diaginfo:"FRXPR01MB0456"
x-beserver:"FRXPR01MB0456"
x-feserver:
0:"LEJPR01CA0057"
1:"FRAPR01CA0084"
x-powered-by:"ASP.NET"
www-authenticate:"Bearer client_id="00000002-0000-0ff1-ce00-000000000000", trusted_issuers="00000001-0003-0000-c000-000000000000@*,00000002-0000-0ff1-ce00-100000000002@84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa", token_types="app_asserted_user_v1 service_asserted_app_v1", authorization_uri="https://login.microsoftonline.de/common/oauth2/authorize", error="invalid_token",Basic Realm="",Basic Realm="",Basic Realm="""
date:"Mon, 09 Jul 2018 09:46:28 GMT"
content-length:"0"
Response Body:
- 我做错了什么?
- PP_E_RPS_INVALIDCONFIG 是什么意思?
- 在哪里可以创建目录
C:\Program Files\Microsoft Passport RPS\LiveIdConfig
?
问题出在令牌上。外观还行,里面就不行了。
使用 Office 365 Deutschland,您必须使用 Azure Active Directory 身份验证端点 V1.0(端点中没有版本号 url 表示 V1.0)。对于国际,您应该使用 V2.0 端点。
V2 enpoint 需要范围内的 resource 提示:https://outlook.office.com/Calendars.Read
。
V1 端点忽略范围(以及其中的资源提示)并需要一个名为 resource 的附加 OAuth2 uri 参数。这些错误并没有给我指明正确的方向。
但它在 this point.
中被(严重地)记录了下来
resource
recommended
The App ID URI of the target web API (secured resource).
To find the App ID URI, in the Azure Portal, click Azure Active Directory,
click Application registrations, open the application's Settings page, then click Properties.
It may also be an external resource like https://graph.microsoft.com.
This is required in one of either the authorization or token requests.
To ensure fewer authentication prompts place it in the authorization request to ensure
consent is received from the user.
我认为 V1.0 应该说 需要。
这里是我的工作授权端点调用:
https://login.microsoftonline.de/common/oauth2/authorize?response_type=code&client_id=c9000000-0000-0000-0000-000000000007&redirect_uri=http://localhost:11184/&state=1P3S9RvgQyfd3xLXmbhPcYD12aNHYkBF&scope=offline_access%20Calendars.Read&resource=https://outlook.office.de
顺便说一句:如果您将 resource 参数与 V2.0 端点一起使用,则会出现错误:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=6262047e-0000-0000-0000-000000000007&redirect_uri=http://localhost:11184/&state=2pSIj7o7dJJ0bGIv0p1ZfRjK6DV2duwM&scope=offline_access%20https://outlook.office.com/Calendars.Read&resource=https://outlook.office.com
AADSTS90100: The 'resource' request parameter is not supported.
我正在使用 Microsoft Office 365 REST API 从 Office 365 和 Outlook.com 帐户读取日历项目。 效果不错。
现在,我需要从 Office 365 Deutschland 个帐户中读取相同的内容。那是行不通的。
我已经发现以下内容:
使用另一个端点登录
国际:https://login.microsoftonline.com/common/oauth2/v2.0/authorize
德国:https://login.microsoftonline.de/common/oauth2/authorize
为 REST 使用另一个端点 API
国际:https://outlook.office.com/api/v2.0/me/calendar/events
德国:https://outlook.office.de/api/v2.0/me/calendar/events
需要另一个ClientID/ClientSecret
国际:https://apps.dev.microsoft.com
德国:https://portal.microsoftazure.de
使用不同的 oauth2 范围
国际:offline_access https://outlook.office.com/Calendars.Read
德国:offline_access openid https://outlook.office.de/Calendars.Read
有了这些,我就可以获得 OAuth2 访问令牌。但是当我打电话给
https://outlook.office.de/api/v2.0/me
或
https://outlook.office.de/api/v2.0/me/calendarview?startDateTime=2018-01-01T01:00:00&endDateTime=2018-10-31T23:00:00
使用该令牌,我只收到以下错误:
Request Headers:
cache-control:"no-cache"
postman-token:"b765d2d1-9ffc-4016-8216-38678af4f245"
authorization:"Bearer AQA*** snip for security***gAA"
user-agent:"PostmanRuntime/7.1.5"
accept:"*/*"
host:"outlook.office.de"
cookie:"ClientId=DFDA316304974E36A43D11CF7BB6D8A3; OIDC=1; OpenIdConnect.nonce.v3.y7kDkk7dHuGjDZ9PZ_xiLj0CjfuLbQt629j5MuTcNp8=636667242602536754.c00ff4a6-e523-4dff-b1ce-24d1d024ce67"
accept-encoding:"gzip, deflate"
Response Headers:
server:"Microsoft-IIS/10.0"
request-id:"e59f5e5e-0980-4914-9087-064270bdd233"
x-calculatedfetarget:"LEJPR01CU002.internal.outlook.com"
x-backendhttpstatus:
0:"401"
1:"401"
x-feproxyinfo:"LEJPR01CA0057.DEUPRD01.PROD.OUTLOOK.DE"
x-calculatedbetarget:"FRXPR01MB0456.DEUPRD01.PROD.OUTLOOK.DE"
x-rum-validated:"1"
x-ms-diagnostics:"2000010;reason="ErrorCode: 'PP_E_RPS_INVALIDCONFIG'. Message: 'Invalid configuration. Check event log for actions.%0d%0a Internal error: Config directory does not exist; config directory must exist and be an absolute path:C:\Program Files\Microsoft Passport RPS\LiveIdConfig.'";error_category="invalid_msa_ticket""
x-besku:"Gen8"
x-diaginfo:"FRXPR01MB0456"
x-beserver:"FRXPR01MB0456"
x-feserver:
0:"LEJPR01CA0057"
1:"FRAPR01CA0084"
x-powered-by:"ASP.NET"
www-authenticate:"Bearer client_id="00000002-0000-0ff1-ce00-000000000000", trusted_issuers="00000001-0003-0000-c000-000000000000@*,00000002-0000-0ff1-ce00-100000000002@84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa", token_types="app_asserted_user_v1 service_asserted_app_v1", authorization_uri="https://login.microsoftonline.de/common/oauth2/authorize", error="invalid_token",Basic Realm="",Basic Realm="",Basic Realm="""
date:"Mon, 09 Jul 2018 09:46:28 GMT"
content-length:"0"
Response Body:
- 我做错了什么?
- PP_E_RPS_INVALIDCONFIG 是什么意思?
- 在哪里可以创建目录
C:\Program Files\Microsoft Passport RPS\LiveIdConfig
?
问题出在令牌上。外观还行,里面就不行了。
使用 Office 365 Deutschland,您必须使用 Azure Active Directory 身份验证端点 V1.0(端点中没有版本号 url 表示 V1.0)。对于国际,您应该使用 V2.0 端点。
V2 enpoint 需要范围内的 resource 提示:https://outlook.office.com/Calendars.Read
。
V1 端点忽略范围(以及其中的资源提示)并需要一个名为 resource 的附加 OAuth2 uri 参数。这些错误并没有给我指明正确的方向。
但它在 this point.
中被(严重地)记录了下来resource
recommended
The App ID URI of the target web API (secured resource).
To find the App ID URI, in the Azure Portal, click Azure Active Directory,
click Application registrations, open the application's Settings page, then click Properties.
It may also be an external resource like https://graph.microsoft.com.
This is required in one of either the authorization or token requests.
To ensure fewer authentication prompts place it in the authorization request to ensure
consent is received from the user.
我认为 V1.0 应该说 需要。
这里是我的工作授权端点调用:
https://login.microsoftonline.de/common/oauth2/authorize?response_type=code&client_id=c9000000-0000-0000-0000-000000000007&redirect_uri=http://localhost:11184/&state=1P3S9RvgQyfd3xLXmbhPcYD12aNHYkBF&scope=offline_access%20Calendars.Read&resource=https://outlook.office.de
顺便说一句:如果您将 resource 参数与 V2.0 端点一起使用,则会出现错误:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=6262047e-0000-0000-0000-000000000007&redirect_uri=http://localhost:11184/&state=2pSIj7o7dJJ0bGIv0p1ZfRjK6DV2duwM&scope=offline_access%20https://outlook.office.com/Calendars.Read&resource=https://outlook.office.com
AADSTS90100: The 'resource' request parameter is not supported.