获取所有群组成员的日历事件,通过Power Automate。

huangapple go评论88阅读模式
英文:

Get Calendar Events of all group members via Power Automate

问题

我想通过Power Automate获取组织/团队中所有成员的日历事件。目前,我看到的“获取日历(V2)”和“获取事件的日历视图(V3)”只返回用户自己的相应值(拥有该流的用户)。我想知道是否有办法获取组成员的日历事件,考虑到他们已经授予了与组织成员共享所有日历数据的相应权限。

对此的任何帮助将不胜感激。

谢谢!

英文:

I want to get the Calendar Events of all of the members in the organization/team via Power Automate. As I see now the "Get Calendars (V2)" and the "Get Calendar View of Events (V3)" only return the corresponding values of the user itself (the one who owns the flow). I was wondering if there's a way to get the calendar events of the group members given the fact that they've given the corresponding permission to share all the calendar data with the organization members.

Any help on this will be much appreciated.

Thanks!

答案1

得分: 0

内置连接器将使用当前用户。
我不认为你可以以这种方式模拟用户。
最佳方法或替代方法是使用带有服务帐户的Graph API(Azure AD应用程序注册)。您可以获取任何人的事件,因此可以获取组中的每个用户的事件。

获取/用户/{id | userPrincipalName}/日历/事件

获取/组/{id}/成员

要使用Power Automate调用Graph API,您需要HTTP连接器(这是高级连接器,必须为您的环境启用连接器)

您必须在Azure AD(或Microsoft Entra)中声明一个服务帐户:

  • 创建新的应用程序注册(应用程序>应用程序注册)

    • 复制客户端ID
    • 复制租户ID
  • 添加以下权限(应用程序>应用程序注册>API权限)

    • Graph API>应用程序>Calendars.Read.All
    • Graph API>应用程序>Directory.Read.All
    • Graph API>应用程序>GroupMember.Read.All
  • 授予权限的管理员同意

  • 生成客户端密钥(应用程序>应用程序注册>证书和密钥>客户端密钥)

在Power Automate中,创建一个新的云流程,例如带有组ID作为输入的按钮。

声明变量:

  • 应用程序注册上的客户端ID
  • 应用程序注册上的客户端密钥
  • 租户ID
  • 用于存储所有事件的数组

接下来,使用通用HTTP连接器调用Graph API以获取组成员

方法:GET
URI:https://graph.microsoft.com/v1.0/groups/<输入的组ID>/members
标头:Content-Type application/json
标头:接受应用程序/JSON
身份验证:Active Directory OAuth
租户:您的租户ID变量
受众:https://graph.microsoft.com
客户端ID:您的客户端ID变量
凭据类型:密钥
密钥:您的客户端密钥变量

将结果转换为JSON,使用以下架构:

{
"type": "object",
"properties": {
    "@@odata.context": {
        "type": "string"
    },
    "value": {
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "mail": {
                    "type": "string"
                }
            },
            "required": [
                "id",
                "mail"
            ]
        }
    }
}
}

对于每个成员,调用Graph API以获取用户的事件

方法:GET
URI:https://graph.microsoft.com/v1.0/users/<JSON foreach中的用户ID>/事件
标头:Content-Type application/json
标头:接受应用程序/JSON
身份验证:Active Directory OAuth
租户:您的租户ID变量
受众:https://graph.microsoft.com
客户端ID:您的客户端ID变量
凭据类型:密钥
密钥:您的客户端密钥变量

将结果转换为JSON,使用以下架构:

{
"type": "object",
"properties": {
    "@@odata.context": {
        "type": "string"
    },
    "value": {
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "@@odata.etag": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "createdDateTime": {
                    "type": "string"
                },
                "lastModifiedDateTime": {
                    "type": "string"
                },
                "changeKey": {
                    "type": "string"
                },
                "categories": {
                    "type": "array"
                },
                "transactionId": {
                    "type": "string"
                },
                "originalStartTimeZone": {
                    "type": "string"
                },
                "originalEndTimeZone": {
                    "type": "string"
                },
                "iCalUId": {
                    "type": "string"
                },
                "reminderMinutesBeforeStart": {
                    "type": "integer"
                },
                "isReminderOn": {
                    "type": "boolean"
                },
                "hasAttachments": {
                    "type": "boolean"
                },
                "subject": {
                    "type": "string"
                },
                "bodyPreview": {
                    "type": "string"
                },
                "importance": {
                    "type": "string"
                },
                "sensitivity": {
                    "type": "string"
                },
                "isAllDay": {
                    "type": "boolean"
                },
                "isCancelled": {
                    "type": "boolean"
                },
                "isOrganizer": {
                    "type": "boolean"
                },
                "responseRequested": {
                    "type": "boolean"
                },
                "seriesMasterId": {},
                "showAs": {
                    "type": "string"
                },
                "type": {
                    "type": "string"
                },
                "webLink": {
                    "type": "string"
                },
                "onlineMeetingUrl": {},
                "isOnlineMeeting": {
                    "type": "boolean"
                },
                "onlineMeetingProvider": {
                    "type": "string"
                },
                "allowNewTimeProposals": {
                    "type": "boolean"
                },
                "occurrenceId": {},
                "isDraft": {
                    "type": "boolean"
                },
                "hideAttendees": {
                    "type": "boolean"
                },
                "responseStatus": {
                    "type": "object",
                    "properties": {
                        "response": {
                            "type": "string"
                        },
                        "time": {
                            "type": "string"
                        }
                    }
                },
                "body": {
                    "type": "object",
                    "properties": {
                        "contentType": {
                            "type": "string"
                        },
                        "content": {
                            "type": "string"
                        }
                    }
                },
                "start": {
                    "type": "object",
                    "properties": {
                        "dateTime": {
                            "type": "string"
                        },
                        "timeZone": {
                            "type": "string"
                        }
                    }
                },
                "end": {
                    "type": "object",
                    "properties": {
                        "dateTime": {
                            "type": "string"
                        },
                        "timeZone": {
                            "type": "string"
                        }
                    }
英文:

The built-in connector will use the current user.
I don't think you can impersonate a user this way.
The best approach or alternative is to use Graph API with a servcie account (Azure AD app registration). You can get events from anyone, so from each users part of a group.

GET /users/{id | userPrincipalName}/calendar/events

GET /groups/{id}/members

To call Graph API with Power Automate you will need HTTP connector (it's a premium connector and the connector must be enable for your environment)

You have to declare a service account in Azure AD (or Microsoft Entra):

  • Create a new app registration (Applications > App registrations)
    • Copy the client id
    • Copy the tenant id

获取所有群组成员的日历事件,通过Power Automate。

  • Add the following permissions (Applications > App registrations > API permissions)
    • Graph API > Application > Calendars.Read.All
    • Graph API > Application > Directory.Read.All
    • Graph API > Application > GroupMember.Read.All
  • Grant admin consent for the permissions

获取所有群组成员的日历事件,通过Power Automate。

  • Generate a client secret (Applications > App registrations > Certificate & secrets > Client secrets)

In Power Automate, create a new cloud flow, for example a button with the group id as input.

Declare variables:

  • Client ID on the app registration
  • Client secret for the app registration
  • Tenant ID
  • Array to store all the events

获取所有群组成员的日历事件,通过Power Automate。

Next, call Graph API to get group members with the generic HTTP connector

Method: GET
URI: https://graph.microsoft.com/v1.0/groups/&lt;your group id input&gt;/members
Headers: Content-Type application/json
Headers: Accept application/json
Authentication: Active Directory OAuth
Tenant: your tenant id variable
Audience: https://graph.microsoft.com
Client ID: your client id variable
Crendential Type: Secret
Secret: your client secret variable

获取所有群组成员的日历事件,通过Power Automate。

Transform the result in JSON using the schema:

{
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
    &quot;@@odata.context&quot;: {
        &quot;type&quot;: &quot;string&quot;
    },
    &quot;value&quot;: {
        &quot;type&quot;: &quot;array&quot;,
        &quot;items&quot;: {
            &quot;type&quot;: &quot;object&quot;,
            &quot;properties&quot;: {
                &quot;id&quot;: {
                    &quot;type&quot;: &quot;string&quot;
                },
                &quot;mail&quot;: {
                    &quot;type&quot;: &quot;string&quot;
                }
            },
            &quot;required&quot;: [
                &quot;id&quot;,
                &quot;mail&quot;
            ]
        }
    }
}
}

For each members, call Graph API to get user's events

Method: GET
URI: https://graph.microsoft.com/v1.0/users/&lt;user id fron json foreach&gt;/event
Headers: Content-Type application/json
Headers: Accept application/json
Authentication: Active Directory OAuth
Tenant: your tenant id variable
Audience: https://graph.microsoft.com
Client ID: your client id variable
Crendential Type: Secret
Secret: your client secret variable

获取所有群组成员的日历事件,通过Power Automate。

Transform the result in JSON using the schema:

{
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;@@odata.context&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;value&quot;: {
&quot;type&quot;: &quot;array&quot;,
&quot;items&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;@@odata.etag&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;id&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;createdDateTime&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;lastModifiedDateTime&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;changeKey&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;categories&quot;: {
&quot;type&quot;: &quot;array&quot;
},
&quot;transactionId&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;originalStartTimeZone&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;originalEndTimeZone&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;iCalUId&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;reminderMinutesBeforeStart&quot;: {
&quot;type&quot;: &quot;integer&quot;
},
&quot;isReminderOn&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;hasAttachments&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;subject&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;bodyPreview&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;importance&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;sensitivity&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;isAllDay&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;isCancelled&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;isOrganizer&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;responseRequested&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;seriesMasterId&quot;: {},
&quot;showAs&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;type&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;webLink&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;onlineMeetingUrl&quot;: {},
&quot;isOnlineMeeting&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;onlineMeetingProvider&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;allowNewTimeProposals&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;occurrenceId&quot;: {},
&quot;isDraft&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;hideAttendees&quot;: {
&quot;type&quot;: &quot;boolean&quot;
},
&quot;responseStatus&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;response&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;time&quot;: {
&quot;type&quot;: &quot;string&quot;
}
}
},
&quot;body&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;contentType&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;content&quot;: {
&quot;type&quot;: &quot;string&quot;
}
}
},
&quot;start&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;dateTime&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;timeZone&quot;: {
&quot;type&quot;: &quot;string&quot;
}
}
},
&quot;end&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;dateTime&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;timeZone&quot;: {
&quot;type&quot;: &quot;string&quot;
}
}
},
&quot;location&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;displayName&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;locationType&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;uniqueIdType&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;address&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {}
},
&quot;coordinates&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {}
}
}
},
&quot;locations&quot;: {
&quot;type&quot;: &quot;array&quot;
},
&quot;recurrence&quot;: {},
&quot;attendees&quot;: {
&quot;type&quot;: &quot;array&quot;
},
&quot;organizer&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;emailAddress&quot;: {
&quot;type&quot;: &quot;object&quot;,
&quot;properties&quot;: {
&quot;name&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;address&quot;: {
&quot;type&quot;: &quot;string&quot;
}
}
}
}
},
&quot;onlineMeeting&quot;: {},
&quot;calendar@odata.associationLink&quot;: {
&quot;type&quot;: &quot;string&quot;
},
&quot;calendar@odata.navigationLink&quot;: {
&quot;type&quot;: &quot;string&quot;
}
},
&quot;required&quot;: [
&quot;@@odata.etag&quot;,
&quot;id&quot;,
&quot;createdDateTime&quot;,
&quot;lastModifiedDateTime&quot;,
&quot;changeKey&quot;,
&quot;categories&quot;,
&quot;transactionId&quot;,
&quot;originalStartTimeZone&quot;,
&quot;originalEndTimeZone&quot;,
&quot;iCalUId&quot;,
&quot;reminderMinutesBeforeStart&quot;,
&quot;isReminderOn&quot;,
&quot;hasAttachments&quot;,
&quot;subject&quot;,
&quot;bodyPreview&quot;,
&quot;importance&quot;,
&quot;sensitivity&quot;,
&quot;isAllDay&quot;,
&quot;isCancelled&quot;,
&quot;isOrganizer&quot;,
&quot;responseRequested&quot;,
&quot;seriesMasterId&quot;,
&quot;showAs&quot;,
&quot;type&quot;,
&quot;webLink&quot;,
&quot;onlineMeetingUrl&quot;,
&quot;isOnlineMeeting&quot;,
&quot;onlineMeetingProvider&quot;,
&quot;allowNewTimeProposals&quot;,
&quot;occurrenceId&quot;,
&quot;isDraft&quot;,
&quot;hideAttendees&quot;,
&quot;responseStatus&quot;,
&quot;body&quot;,
&quot;start&quot;,
&quot;end&quot;,
&quot;location&quot;,
&quot;locations&quot;,
&quot;recurrence&quot;,
&quot;attendees&quot;,
&quot;organizer&quot;,
&quot;onlineMeeting&quot;,
&quot;calendar@odata.associationLink&quot;,
&quot;calendar@odata.navigationLink&quot;
]
}
}
}
}

获取所有群组成员的日历事件,通过Power Automate。

Activate and start the flow with a group id as input:

获取所有群组成员的日历事件,通过Power Automate。

huangapple
  • 本文由 发表于 2023年6月1日 20:20:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76381797.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定