public async Task RunAsync(string[] args, AppInfo appInfo, Func <Task> whenFirstInstance)
        {
            if (IsApplicationFirstInstance(appInfo.Name))
            {
                // args[0] is always the path to the application
                // update system registry
                AuthConfig.WinDesktopUseBrowserAuth(appInfo, args[0]);

                await whenFirstInstance();
            }
            else
            {
                // We are not the first instance, send the argument received from browser auth, to the currently running instance
                if (args.Length >= 2)
                {
                    var ack = InterProcessCom.SendAuthResponse(args[1]);

                    Console.WriteLine(ack);
                    Console.WriteLine($"Switch back to your application..");
                    Thread.Sleep(1000); // allow a short moment to percieve the above writelines
                }

                // Close app
                return;
            }
        }
예제 #2
0
        public async Task <Session> AuthenticateAsync()
        {
            // Authentication with the SAFE browser
            await AuthenticationWithBrowserAsync();

            var authResponse = InterProcessCom.ReceiveAuthResponse();

            // Create session from response
            return(await ProcessAuthenticationResponse(authResponse));
        }