0

我已经在 .NET Framework (C# Winforms) 中使用 PKCE 流完成了 OAuth2.0。

现在我手里有 tokens_response。

但我想知道是否有可能获取所有组织(不仅仅是一个)?

4

1 回答 1

1

您可以使用 /connections 端点检查您可以使用给定令牌访问的组织(租户),如下所示:

GET https://api.xero.com/connections
Authorization: "Bearer " + access_token
Content-Type: application/json

Response:
[
    {
        "id": "e1eede29-f875-4a5d-8470-17f6a29a88b1",
        "authEventId": "d99ecdfe-391d-43d2-b834-17636ba90e8d",
        "tenantId": "70784a63-d24b-46a9-a4db-0e70a274b056",
        "tenantType": "ORGANISATION",
        "tenantName": "Maple Florist",
        "createdDateUtc": "2019-07-09T23:40:30.1833130",
        "updatedDateUtc": "2020-05-15T01:35:13.8491980"
    },
    {
        "id": "32587c85-a9b3-4306-ac30-b416e8f2c841",
        "authEventId": "d0ddcf81-f942-4f4d-b3c7-f98045204db4",
        "tenantId": "e0da6937-de07-4a14-adee-37abfac298ce",
        "tenantType": "ORGANISATION",
        "tenantName": "Adam Demo Company (NZ)",
        "createdDateUtc": "2020-03-23T02:24:22.2328510",
        "updatedDateUtc": "2020-05-13T09:43:40.7689720"
    }
]

如果您需要比组织的 ID 和名称更多的信息,则需要为每个单独调用 /organisation 端点。

连接端点在此文档页面的第 5 节中有更多描述:https ://developer.xero.com/documentation/oauth2/auth-flow

于 2020-08-16T00:10:54.663 回答