Skip to content

Commit

Permalink
Fixing issue using bearer token on vsts.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarqueWarrior committed Jul 10, 2018
1 parent f7fd6e3 commit 74d588f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .docs/Add-VSTeamAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Note: You must run PowerShell as an Adminstrator to store at the Machine level.
### -------------------------- EXAMPLE 7 --------------------------

```PowerShell
PS C:\> Add-VSTeamAccount -Account mydemos -Token $(System.AccessToken) -BearerToken
PS C:\> Add-VSTeamAccount -Account mydemos -Token $(System.AccessToken) -UseBearerToken
```

Will add the account and use the OAuth Token provided by VSTS when you check the *Allow scripts to access OAuth token* checkbox on the phase. Using this method removes the need to create a Personal Access Token. Note -Token is just an alais for -PersonalAccessToken.
Expand Down Expand Up @@ -146,7 +146,7 @@ Type: SwitchParameter
Parameter Sets: Windows
```
### -BearerToken
### -UseBearerToken
Switches the authorzation from Basic to Bearer. You still use the PAT for PersonalAccessToken parameters to store the token.
Expand Down
2 changes: 1 addition & 1 deletion .docs/Add-VSTeamProfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Type: SwitchParameter
Parameter Sets: Windows
```
### -BearerToken
### -UseBearerToken
Switches the authorzation from Basic to Bearer. You still use the PAT for PersonalAccessToken parameters to store the token.
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ The cases of every file is very important. This module is to be used on Windows,

## Release Notes

### 3.0.1

Huge review of the docs and added support for bearer auth.

Bearer auth will allow you to use the OAuth token created by VSTS during your build and release and not have to create a PAT. Just check the 'Allow scripts to access OAuth token' option on your phase. Then you can add an account by using the -UseBearerToken switch and passing in the $(System.AccessToken) variable.

```PowerShell
Add-VSTeamAccount -Account mydemos -Token $(System.AccessToken) -UseBearerToken
```

### 3.0.0

There is a breaking change with calls to Add-VSTeamKubernetesEndpoint. The acceptUntrustedCerts and generatePfx parameters have been changed from boolean to switch. So any calls that contained:
Expand Down
3 changes: 2 additions & 1 deletion src/team.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function _clearEnvironmentVariables {
[System.Environment]::SetEnvironmentVariable("TEAM_PROJECT", $null, $Level)
}

_setEnvironmentVariables -Level $Level -Pat '' -Acct '' -BearerToken ''
_setEnvironmentVariables -Level $Level -Pat '' -Acct '' -UseBearerToken ''
}

function Get-VSTeamInfo {
Expand Down Expand Up @@ -241,6 +241,7 @@ function Add-VSTeamAccount {

if ($UseBearerToken.IsPresent) {
$token = $_pat
$encodedPat = ''
}
else {
$token = ''
Expand Down

0 comments on commit 74d588f

Please sign in to comment.