配置团队通过MS Graph API呼叫转发策略
TL; dr:
设置团队呼叫用户的转发策略的MS图API是什么?
背景:
目前,我正在尝试将基于Lync/Skype的.NET应用程序迁移到团队。 团队相关的部分是关于设置一些特定用户的呼叫转发偏好。 这些用户可以启用直接路由,即您可以调用固定的PSTN/后缀号码,并且用户将在其手机上接收电话。该手机号码取决于轮班,因此该程序将其调整为当时有班次职责的人。
到目前为止,我尝试过什么?
- 我可以使用MS Graph API进行身份验证。
- 我知道为此目的有TAC扩展([ 1 ]和[ 2 ])
- 还有一个powershell扩展名[ 3 ]
- 我不是第一个提出问题的人,但是其他线程通常会卡住[ 4 )
- call-redirect 不是我想要的,因为我不是在这些情况下积极倾听。
- 有一个“ nofollow noreferrer”> github for team for Teams for Teams for Teams for Seams for Seams for Seams casss for Seams speachs casss casss casss casss casss casss cloce ,但不幸的是没有来源。 。
-
- /en-us/graph/api/resources/userettings?view = graph-rest-beta“ rel =“ nofollow noreferrer”>用户设置输入,您可以在其中更换偏移而不是呼叫转发
计划B?
Update 2022-06-20
- 我开始反映PS模块。因此,API似乎像
https://api.interfaces.records.teams.teams.microsoft.com/skype.voicegroup/userroutingsettings/ + userId
- teams user ID可以检索
- 一些团队的某些部分仍然依靠较旧的(仅德语,对不起)
更新2022-06-30
可以改进的POC将看起来像这样(...如果我已经打包到通常的AccearireTokenOkeNonBehalfof中,那么我会添加它作为答案... )
Imports System.IO
Imports Microsoft.Identity.Client
Imports System.Globalization
Imports System.Net.Http
Imports System.Text
Imports System.Net.Http.Headers
Imports System.Net
Imports Newtonsoft.Json
Imports System.IdentityModel.Tokens.Jwt
Public Class LyncTest
Public Shared Sub Test()
Dim InstanceId As String = "https://login.microsoftonline.com/"
Dim RedirectURI As String = "https://login.microsoftonline.com/common/oauth2/nativeclient"
' Ids / Secrets and can be found on your Azure application page
Dim TenantId As String = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
Dim AppId As String = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
Dim secretVal As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Dim username As String = "[email protected]"
Dim password As String = "xxxxxxxxxxxx"
' Teams scope
Dim scope As String = "48ac35b8-9aa8-4d74-927d-1f4a14a0b239/.default"
Dim httpClient = New HttpClient()
' start resource owner password credential flow
' see https://learn.microsoft.com/en-us/powershell/module/teams/connect-microsoftteams?view=teams-ps#example-4-connect-to-microsoftteams-using-accesstokens
Dim baseParam As String =
$"client_id={AppId}" &
$"&username={WebUtility.UrlEncode(username)}" &
$"&password={WebUtility.UrlEncode(password)}" &
$"&grant_type=password" &
$"&client_secret={WebUtility.UrlEncode(secretVal)}" &
$"&scope={scope}"
' get user_impersonation token
Dim tokenReq As New HttpRequestMessage(HttpMethod.Post, $"https://login.microsoftonline.com/{TenantId}/oauth2/v2.0/token") With {
.Content = New StringContent(baseParam, Encoding.UTF8, "application/x-www-form-urlencoded")
}
Dim TokenRes As HttpResponseMessage = httpClient.SendAsync(tokenReq).Result
Dim TokenObj As GraphToken = JsonConvert.DeserializeObject(Of GraphToken)(TokenRes.Content.ReadAsStringAsync.Result())
Dim JwtReader As New JwtSecurityTokenHandler
Dim JwtToken As JwtSecurityToken = JwtReader.ReadToken(TokenObj.AccessToken)
Dim UserOid As String = JwtToken.Payload("oid")
' set user calling routing
Dim RoutingURL As String = $"https://api.interfaces.records.teams.microsoft.com/Skype.VoiceGroup/userRoutingSettings/{UserOid}"
httpClient.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("Bearer", TokenObj.AccessToken)
Dim RoutingJSON As String =
"{""sipUri"":""sip:[email protected]""," &
"""forwardingSettings"":{""isEnabled"":false,""forwardingType"":""Simultaneous"",""targetType"":""Unknown"",""target"":""""}," &
"""unansweredSettings"":{""isEnabled"":true,""targetType"":""SingleTarget"",""target"":""+491701234567"",""delay"":""00:00:20""}," &
"""callGroupDetails"":{""targets"":[],""order"":""Simultaneous""},""callGroupMembershipSettings"":{""callGroupMembershipDetails"":[]}}"
Dim RoutingReq As New HttpRequestMessage(HttpMethod.Post, RoutingURL) With {
.Content = New StringContent(RoutingJSON, Encoding.UTF8, "application/json")
}
Dim RoutingRes As HttpResponseMessage = httpClient.SendAsync(RoutingReq).Result
Console.WriteLine(If(RoutingRes.IsSuccessStatusCode, "success", "failed"))
End Sub
Public Class GraphToken
<JsonProperty(PropertyName:="access_token")>
Public Property AccessToken As String
<JsonProperty(PropertyName:="expires_in")>
Public Property ExpiresIn As Integer
<JsonProperty(PropertyName:="ext_expires_in")>
Public Property ExpiresInExt As Integer
<JsonProperty(PropertyName:="scope")>
Public Property Scope As String
<JsonProperty(PropertyName:="token_type")>
Public Property TokenType As String
End Class
End Class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有可用于设置用户的团队转发策略的图形API。
任何用户策略/租户配置仅通过PowerShell或Admin Portal公开。
There is no Graph API available for setting the teams call forwarding policy of an user.
Any user policy/tenant configuration are only exposed through PowerShell or admin portal now.
如果您只想在不接听CallID并传输单个呼叫的情况下更改团队中的转发状态,那么使用PowerShell可以使用PowerShell:
安装M $ Teams的PowerShell模块。
https://www.powershellgallery.com/ppackages/ppackages/packages/microsoftteams 使用
install -module -name microsoftteams -requiredversion 4.6.0 -allowClobber
假设您使用 set-csuserCallingSettings命令,例如
set-csusercallingsettings-identity IsunansweredEnabled $ false
set-csusercallingsettings-identity
“如果启用语音邮件,则会引发错误,
这将更改输送到所选身份的所有调用的转发状态。请注意,用户可以将其更改为GUI团队。
If you just want to change the forwarding status in Teams without catching callId and transferring individual calls, there is a simpler way by using PowerShell:
Install PowerShell module for M$Teams
https://www.powershellgallery.com/packages/MicrosoftTeams straight to PowerShell, for example by using
Install-Module -Name MicrosoftTeams -RequiredVersion 4.6.0 -AllowClobber
Assuming that you have permission set up forwarding by using Set-CsUserCallingSettings command, for example
Set-CsUserCallingSettings -Identity [email protected] -IsUnansweredEnabled $FALSE
Set-CsUserCallingSettings -Identity [email protected] -IsForwardingEnabled $true -ForwardingType Immediate -ForwardingTargetType SingleTarget -ForwardingTarget "+123456789"
In theory, only the second line is necessary, but I've noticed that PowerShell throws an error if Voicemail is enabled
This will change the forwarding status for all calls incoming to the selected identity. Note, that the user can change it still in Teams GUI.