Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Get token automatically #172

Open
danroot opened this issue Feb 1, 2023 · 1 comment
Open

Feature Request: Get token automatically #172

danroot opened this issue Feb 1, 2023 · 1 comment

Comments

@danroot
Copy link

danroot commented Feb 1, 2023

I would like to write scripts to automate various devops tasks for developers. I'm able to do so with a personal access token, like this:

$pat = get-content .devopspat -ErrorAction SilentlyContinue
$_=Connect-ADO -Organization $org -PersonalAccessToken $pat -UseDefaultCredentials -ErrorAction Stop

However I would like to make the scripts not require storing a pat in clear text. I'd like to do similar to "az login" - if the current session doesn't have auth token in keychain, open the browser to get one and then use that for future calls. Is this feasible today?

If not feasible, what is the recommended way to safely store pats for use in scripts?

@StartAutomating
Copy link
Owner

StartAutomating commented Feb 24, 2023

@danroot Thanks for the issue.

I'd love it if there was an easy way to get the PAT after az login. If you know of one, or see any environment variable change, I could probably change the way things work here.

As far as the general question goes...

I have some very old solutions for this that will work on Windows, but I'm not going to spend my time explaining them.

Instead, I'll redirect you to the modern / official answer on this, from the PowerShell team:

Set-Secret and Get-Secret should do most of the trick for you. You'll need to install the SecretManagement module and any number of extensions for secret management.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants