Forum Discussion
Re: Authenticating with an access token Connect-MicrosoftTeams
4 Replies
- danielandrewbrowneCopper Contributor
MattLadewigWhen I do this I now get "Object reference not set to an instance of an object." on the Connect-MicrosoftTeams line.
- Andres-BohrenSteel Contributor
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
- Andres-BohrenSteel Contributor
- Andres-BohrenSteel Contributor
Tried with ClientSecret. Same Result.
$TenantId = "tenantname.onmicrosoft.com"
$AppID = "546f064a-baa2-4eb9-8b68-70c79b91942b" #TeamsPS
$ClientSecret = ConvertTo-SecureString "MyClientSecret" -AsPlainText -Force#GraphAccessToken
$Scope = "https://graph.microsoft.com/.default"
$Token = Get-MsalToken -clientID $AppID -ClientSecret $ClientSecret -tenantID $tenantID -Scope $Scope
$GraphAccessToken = $Token.AccessToken
$GraphAccessToken#TeamsAccessToken
$Scope = "48ac35b8-9aa8-4d74-927d-1f4a14a0b239/.default"
$Token = Get-MsalToken -clientID $AppID -ClientSecret $ClientSecret -tenantID $tenantID -Scope $Scope
$TeamsAccessToken = $Token.AccessToken
$TeamsAccessToken#Connect
$AccessTokens = @($GraphAccessToken,$TeamsAccessToken)
Connect-MicrosoftTeams -AccessTokens $AccessTokensRegards
Andres