private static void ConsoleMain()

in wwauth/Google.Solutions.WWAuth/Program.cs [107:151]


        private static void ConsoleMain()
        {
            //
            // Fetch token for current user and output a
            // pluggable auth-compliant result.
            //
            var writer = ConsoleHandle.Out.Writer;
            try
            {
                var options = UnattendedCommandLineOptions
                    .Parse(Environment.CommandLine)
                    .Validate();

                //
                // Create the right token adapter.
                //
                var tokenAdapter = AdapterFactory.CreateTokenAdapter(
                    options,
                    new NullLogger());

                //
                // Acquire a token and write the result to the console
                // (where the calling application will pick it up).
                //
                var token = tokenAdapter
                    .AcquireTokenAsync(
                        Adapters.TokenAcquisitionOptions.None,
                        CancellationToken.None)
                    .Result;

                new PluggableAuthResult(token).WriteTo(writer);
            }
            catch (Exception e)
            {
                //
                // Pluggable auth expects errors to be reported
                // as a result on STDOUT, not on STDERR.
                //
                new PluggableAuthResult(e).WriteTo(writer);
            }
            finally
            {
                writer.Flush();
            }
        }