Mar 24 2021 04:38 PM
May 28 2021 12:28 PM
Jul 21 2021 06:58 AM
Jul 23 2021 08:16 AM - edited Jul 23 2021 08:18 AM
I'm trying to setup something similar in Softerra Adaxes, but I'm not getting very far
$clientId = ""
$clientSecret = ""
$tenantName = "tenant.onmicrosoft.com"
$tenantNameshort = ""
$tenantIdCode = ""
$graphResource = "https://graph.microsoft.com/"
$graphtokenBody = @{
Grant_Type = "client_credentials"
Scope = "https://graph.microsoft.com/.default"
Client_Id = $clientId
Client_Secret = $clientSecret
}
$graphTokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantName/oauth2/v2.0/token" -Method POST -Body $graphtokenBody
$teamsResource = "https://api.interfaces.records.teams.microsoft.com"
$teamstokenBody = @{
Grant_Type = "client_credentials"
Scope = "48ac35b8-9aa8-4d74-927d-1f4a14a0b239/.default"
Client_Id = $clientId
Client_Secret = $clientSecret
}
$TeamsTokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantName/oauth2/v2.0/token" -Method POST -Body $teamstokenBody
Connect-MicrosoftTeams -TenantId $tenantId -AccessTokens @($graphTokenResponse.access_token,$TeamsTokenResponse.access_token)
I get this error:
Connect-MicrosoftTeams : Not supported tenant type.
At C:\scripts\connect-teams.ps1:27 char:1
+ Connect-MicrosoftTeams -TenantId $tenantId -AccessTokens @($graphToke ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : AuthenticationError: (:) [Connect-MicrosoftTeams], ArgumentException
+ FullyQualifiedErrorId : Connect-MicrosoftTeams,Microsoft.TeamsCmdlets.Powershell.Connect.ConnectMicrosoftTeams
If I try something along the lines of
Connect-MicrosoftTeams -TenantId $tenantId -ClientId $clientId -Certificatethumbprint $certificateThumbprint
I get the following:
Connecting to remote server api.interfaces.records.teams.microsoft.com failed with the following error message : The WinRM client cannot process the request....
Aug 17 2021 03:48 AM
Aug 23 2021 03:25 PM
Aug 26 2021 12:33 AM
Aug 26 2021 12:39 AM
Aug 26 2021 07:38 AM
Using Teams 2.5.0
Does not work here. I've created a GitHub Issue to clarify the Permissions needed https://github.com/MicrosoftDocs/office-docs-powershell/issues/8194
Regards
Andres
Aug 26 2021 09:30 AM
@MattLadewigWhen I do this I now get "Object reference not set to an instance of an object." on the Connect-MicrosoftTeams line.
Aug 27 2021 12:56 PM
Oct 01 2021 02:26 PM
Oct 01 2021 03:05 PM
Oct 15 2021 11:47 AM
SolutionOct 26 2021 02:20 PM
Nov 04 2021 05:56 AM
Hi,
We were successfully using Microsoft Teams powershell using Access Tokens. But today we are faced with strange issue:
We are getting error during authentication: Connect-MicrosoftTeams
The provided tokens must have less than 180 seconds difference in the time range of expiration. System.Management.Automation.RemoteException: The provided tokens must have less than 180 seconds difference in the time range of expiration.
We have checked the access tokens expiry, they do differ by more then 180 seconds. We are using Refresh tokens to generate Access tokens. This is done automatically using .NET code, both access tokens are fetched within few milliseconds, yet the expiry differs. And when we use these tokens we get above error.
Has anyone experienced this?
Regards,
Muhammad Usman
Nov 10 2021 02:49 AM
@usman83 Muhammad, we stating to have this same error just today:
"The provided tokens must have less than 180 seconds difference in the time range of expiration."
I've compared these 2 tokens expiration time and there are almost 7 minutes of difference between them. We ask Microsoft to generate the tokens one right after the other.
If you get a solution, please share it here.
Thanks
Nov 10 2021 06:24 PM
We are having the same issue, this was working for till 10/11/2021 and it has suddenly stopped working today.
Nov 11 2021 12:07 PM - edited Nov 15 2021 02:33 AM
Hi @Sridevi-MSFT,
I've also started experiencing this issue today. Was working fine before, but now I get the error: " The provided tokens must have less than 180 seconds difference in the time range of expiration."
Using Teams PowerShell Module 2.3.2 with a graph token and a Teams token that are created at the same time, but the expiration time can be as great as 20min.
Nov 14 2021 01:52 PM
@Sridevi-MSFT Any update on the error with 180 seconds difference in token expiration?
Nov 15 2021 01:51 AM
I am Using Teams PowerShell Module 2.6.1
But i am Still not able to Connect with the Access Tokens.
Any Updates?