Forum Discussion

Re: Authenticating with an access token Connect-MicrosoftTeams

Removing the -AccountId "user@domain.com" parameter should allow you to login. Seems this detail is derived via the tokens now in 2.5.0

4 Replies

  • danielandrewbrowne's avatar
    danielandrewbrowne
    Copper Contributor

    MattLadewigWhen I do this I now get "Object reference not set to an instance of an object." on the Connect-MicrosoftTeams line.

    • Andres-Bohren's avatar
      Andres-Bohren
      Steel Contributor

      I am Using Teams PowerShell Module 2.6.1

       

      But i am Still not able to Connect with the Access Tokens.

      Any Updates?

      • Andres-Bohren's avatar
        Andres-Bohren
        Steel 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 $AccessTokens

         

        Regards
        Andres