Open heaths opened 3 years ago
Digging in a bit more, having some way to force authentication via providers could, for example, make a similar call as to GitHubAuthenticationProvider.manuallyProvideToken
but accept input as opposed to prompting or, better, told to go discover alternative methods like using gh
CLI's token or, for Microsoft auth, using its credential flow even if that means prompting to authorize. If authentication providers each had such a method, this could be abstracted away to a command line switch like:
code --authenticate ${token}@github --sync on # or maybe separate commands if ordering/timing is a concern
Adding @schaabs who is the architect for Azure SDK's DefaultAzureCredential
since I'm probably over-simplifying the solution. I'm wondering, too, if MSAL for JS can help with automated workflows for AAD/MSA, and if a refresh token might be necessary to store in gh
CLI's hosts.yml instead of just reusing the OAuth token. We should probably consult with our colleageus in GitHub in any case.
Profile synchronization is nice, and being able to automate installation of extensions is great for setting up new machines, but keeping a separate list is onerous. Instead, it would be great if signing in could be automated.
For example, could the GitHub authentication provider be changed to support authenticating against stored credentials from the
gh
CLI? We do something similar like this with Azure SDK's DefaultAzureCredential, which a couple of the chained credential providers attempt to securely extract authentication tokens from the Azure (az
) CLI or Azure (Az) PowerShell module. Thegh
CLI already provides a way to automate authentication, or at the very least offloads the responsibility of logging in via Code, mitigating a whole new workflow for non-visual authentication (which doesn't seem to be supported currently).So a machine prep script could: