PowerShellForGitHub
PowerShellForGitHub copied to clipboard
Set-GitHubRepositoryTeamPermission fails on private repos
Issue Details
When using a private repository the Set-GitHubRepositoryTeamPermission throws an error on the collection of teams (teams are part of an org)
Steps to reproduce the issue
Set-GitHubRepositoryTeamPermission -TeamName $repoName `
-RepositoryName $repoName `
-AccessToken $splatParams.AccessToken `
-Permission "Maintain" `
-OwnerName $splatParams.OrganizationName
Verbose logs showing the problem
The remote server returned an error: (401) Unauthorized. 401 | Unauthorized Requires authentication | https://docs.github.com/rest/reference/teams#list-teams
Suggested solution to the issue
If present, the -AccessToken param should be passed in on line 3256: $team = Get-GitHubTeam -OrganizationName $OwnerName -AccessToken $AccessToken
PowerShell Version
5.1.19041.1682
Module Version
Running: 0.16.0 Installed: 0.16.0
Thanks for the catch, @HanwhaARudolph! It looks like all three related functions have the same issue:
Get-GitHubRepositoryPermissionSet-GitHubRepositoryPermissionRemove-GitHubRepositoryPermission
I'll look at getting that fixed in the next day or so.
I'm also curious: Why do you opt to pass-in AccessToken when using the functions as opposed to calling Set-GitHubAuthentication once and having it handled for you. It's certainly more secure to do it with Set-GitHubAuthentication since the access token won't be stored in plaintext in either the console memory or history.
@HowardWolosky I was just testing when ran into it. I plan on using the set-githubauthentication.
Not a high priority fix but something that was inconsistent to the behavior I expected.