SOLVED

Authenticating with an access token Connect-MicrosoftTeams

Brass Contributor
Has anyone tried authenticating with an access token (using -AadAccessToken or -MsAccessToken)? The old version of New-CsOnlineSession had an -OAuthAccessToken param, which accepted a jwt with the PS permissions in the scope, which one could obtain silently, and so avoid login.

New-CsOnlineSession has been dropped and the SfB Connector is end of life in July and Connect-MicrosoftTeams does appear to support token for the telephony functions.
135 Replies

@PhoneMe007, Can you please explain more briefly about the issue.

New-CsOnlineSession has an -OAuthAccessToken param, which accepted a jwt with the Powershell permissions in the scope, which we could obtain silently, and so avoid login to run the Powershell commands. This no longer works for Connect-MicrosoftTeams with any of the voice related cmdlets and functions. We can obtain the token but Powershell returns an error.
Hi @PhoneMe007 could you please check with latest Powershell Teams module. It have the inbuilt sfb connecter features.
No change @teams1535 :frowning_face:
Update: Microsoft has released a preview version (2.1.0) of the Teams PowerShell module which works properly with modern authentication. It’s likely that this version will be pushed through to general availability quite quickly.
Please go through this link for more information.
https://office365itpros.com/2021/03/10/microsoft-updates-teams-powershell-module-2-0/

@teams1535 Unfortunately this method still doesn't work with any of the voice related cmdlets/functions - Get-CsOnlineSession for example is not a recognised cmdlets when you try running it.

 

PS C:\WINDOWS\system32> Set-CsOnlinePSTNUsage -Identity Global -Usage @{add="UnrestrictedPstnUsage"}

Get-CsOnlineSession : Run Connect-MicrosoftTeams before running cmdlets.

At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.2.0\net472\SfBORemotePowershellModule.psm1:57 char:22

+     $remoteSession = & (Get-CsOnlineSessionCommand)

+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-CsOnlineSession], UnauthorizedAccessException

    + FullyQualifiedErrorId : UnauthorizedAccessException,Microsoft.Teams.ConfigApi.Cmdlets.GetCsOnlineSession

 

Invoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an argument

that is not null or empty, and then try the command again.

At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\2.2.0\net472\SfBORemotePowershellModule.psm1:47766 char:38

+ ...    -Session (Get-PSImplicitRemotingSession -CommandName 'Set-CsOnline ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [Invoke-Command], ParentContainsErrorRecordException

    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand

@PhoneMe007 @teams1535

 

Have either of you been able to resolve this issue as I'm experiencing the same?

Nope, and even in 2.3.0 released yesterday it's no better...
@Sridevi-MSFT Have you been able to find a solution?

@SajAccess4 I have taken this to Engineering team will update you immediately once I get any inputs from them.

Thanks @Sridevi-MSFT, appreciate your help
I am facing the same issue on connecting to the Teams module using an access token. Although the command doesnt throw and error, running Skype commands gives me this for the command "Get-CsTeamsCallingPolicy"

Error:
Get-CsOnlineSession : Run Connect-MicrosoftTeams before running cmdlets.
I have experienced the same thing with Get-CsOnlineUser.
what is the use of releasing this powershell if it doesn't work
I am also finding that when connecting with access tokens the Get-CSOnlinePSTNGateway and anything that used to be connected via the new-csonlinesession no longer functions.
If you log in with Connect-MicrosoftTeams interactively then it will work, but this is undesirable for our automation requirements.
Module version 2.3.1
We have implemented a fix which will be available when the 3.0.0 version is released.
What is the likely date for its release?

@priyachads - Currently we don't have any ETA to share.

1 best response

Accepted Solutions
best response confirmed by Jos Verlinde (Microsoft)
Solution
FYI - I raised a ticket, and it should be fixed by mid november.

Issue description:
Cannot properly run Connect-MicrosoftTeams -AccessTokens

Resolution Steps:
Escalated case with our engineering Team
Issue is known bug and currently being fixed
Expecting a fix to go out by NOV mid

View solution in original post