Add support for non-interactive logins on headless machines #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an opinionated approach to support non-interactive logins on headless machines. These types of machines do not have access to a browser, and thus need to receive an authorization code as the starting point to successfully complete the regular OAuth 2.0 Authorization Code flow. This PR implements that and therefore resolves #13, not as a fallback, but explicitly.
Generally it goes as follows:
NonInteractive
set to trueGetToken
process, and you'll be prompted with an inputGetCodeAndConfig
, and complete the login flow in the browser. Take note of the printed result, which is a base64 encoded struct, that holds both the authorization code and the usedoauth2.config
, which is necessary to successfully exchange the code for a token.OAuth2ConfigAndCode
, which is decoded and unmarshalled, after which theoauth.config
in the providedoauth2cli.Config
is overwritten by theoauth2.config
used during the retrieval of the code.Note that the processes can be executed on the same machine (why would you do that? 😄), or on separate machines (the entire goal of this PR).
@int128 let me know what you think!