Skip to content

Commit 80bd267

Browse files
authored
Merge branch 'master' into chrisda
2 parents 62d4168 + 55f3e72 commit 80bd267

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

teams/teams-ps/teams/Connect-MicrosoftTeams.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,31 @@ [email protected] TeamsGCCH xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx xxxxxx
8181
```
8282

8383
### Example 4: Connect to MicrosoftTeams using Accesstokens
84-
This example demonstrates how to sign in using AccessTokens. Admin can reterive Access Tokens. It requires two tokens, MS Graph Access Token and Teams Resource token.
84+
This example demonstrates how to sign in using AccessTokens. Admin can retrieve Access Tokens. It requires two tokens, MS Graph Access Token and Teams Resource token.
85+
86+
A delegated flow, such as Resource Owner Password Credentials (ROPC), must be used, with the following delegated app permissions required.
87+
88+
| API | Grant type | Permission |
89+
|-|-|-|
90+
| Microsoft Graph | Delegated | User.Read.All |
91+
| Microsoft Graph | Delegated | Group.ReadWrite.All |
92+
| Microsoft Graph | Delegated | AppCatalog.ReadWrite.All |
93+
| Skype and Teams Tenant Admin API | Delegated | user_impersonation |
8594

8695
```powershell
87-
$graphtoken = #Get MSGraph Token for following for resource "https://graph.microsoft.com" and scopes "AppCatalog.ReadWrite.All", "Group.ReadWrite.All", "User.Read.All";
88-
$teamstoken = #Get Teams resource token for resource id "48ac35b8-9aa8-4d74-927d-1f4a14a0b239" and scope "user_impersonation";
96+
$tenantid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
97+
$clientid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
98+
$clientsecret = "..."
99+
$username = "[email protected]"
100+
$password = "..."
101+
102+
$uri = "https://login.microsoftonline.com/{0}/oauth2/v2.0/token" -f $tenantid
103+
$body = "client_id={0}&scope=https://graph.microsoft.com/.default&username={1}&password={2}&grant_type=password&client_secret={3}" -f $clientid, $username, [System.Net.WebUtility]::UrlEncode($password), [System.Net.WebUtility]::UrlEncode($clientsecret)
104+
$graphtoken = Invoke-RestMethod $uri -Body $body -Method Post -ContentType "application/x-www-form-urlencoded" -ErrorAction SilentlyContinue | Select-object -ExpandProperty access_token
105+
106+
$uri = "https://login.microsoftonline.com/{0}/oauth2/v2.0/token" -f $tenantid
107+
$body = "client_id={0}&scope=48ac35b8-9aa8-4d74-927d-1f4a14a0b239/.default&username={1}&password={2}&grant_type=password&client_secret={3}" -f $clientid, $username, [System.Net.WebUtility]::UrlEncode($password), [System.Net.WebUtility]::UrlEncode($clientsecret)
108+
$teamstoken = Invoke-RestMethod $uri -Body $body -Method Post -ContentType "application/x-www-form-urlencoded" -ErrorAction SilentlyContinue | Select-object -ExpandProperty access_token
89109
90110
Connect-MicrosoftTeams -AccessTokens @($graphtoken, $teamstoken)
91111
@@ -159,6 +179,9 @@ Accept wildcard characters: False
159179
### -ApplicationId
160180
Specifies the application ID of the service principal.
161181
182+
> [!WARNING]
183+
>This parameter has been removed from the latest versions and replaced by the AccessTokens parameter.
184+
162185
```yaml
163186
Type: String
164187
Parameter Sets: ServicePrincipalCertificate

0 commit comments

Comments
 (0)