コード例 #1
0
        public async Task GetUserInfo()
        {
            var googleUserInfo = await _oAuthAppService.GetUserInfo();

            Assert.NotNull(googleUserInfo.Id);
            Assert.NotNull(googleUserInfo.Email);
            Assert.NotNull(googleUserInfo.Picture);

            OutputHelper.WriteLine("User credentials:");
            OutputHelper.WriteLine($"\tId: {googleUserInfo.Id}");
            OutputHelper.WriteLine($"\tEmail: {googleUserInfo.Email}");
            OutputHelper.WriteLine($"\tName: {googleUserInfo.Name}");
            OutputHelper.WriteLine($"\tETag: {googleUserInfo.ETag}");
            OutputHelper.WriteLine($"\tGender: {googleUserInfo.Gender}");
            OutputHelper.WriteLine($"\tPicture: {googleUserInfo.Picture}");
        }
コード例 #2
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogDebug($"Starting with arguments: {string.Join(" ", Environment.GetCommandLineArgs())}");

            _appLifetime.ApplicationStarted.Register(() =>
            {
                Task.Run(async() =>
                {
                    try
                    {
                        var googleUserInfo = await _oAuthAppService.GetUserInfo();

                        Console.WriteLine("User credentials:");
                        Console.WriteLine($"\tId: {googleUserInfo.Id}");
                        Console.WriteLine($"\tEmail: {googleUserInfo.Email}");
                        Console.WriteLine($"\tName: {googleUserInfo.Name}");
                        Console.WriteLine($"\tETag: {googleUserInfo.ETag}");
                        Console.WriteLine($"\tGender: {googleUserInfo.Gender}");
                        Console.WriteLine($"\tPicture: {googleUserInfo.Picture}");

                        //await _googleScriptAppService.GetFoldersUnderRoot();
                        await _driveAppService.DownloadAndCreateFolders("MonoDrive Test");
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Unhandled exception!");
                    }
                    finally
                    {
                        // Stop the application once the work is done
                        //_appLifetime.StopApplication();
                    }
                }, cancellationToken);
            });

            return(Task.CompletedTask);
        }
コード例 #3
0
 public async Task <string> GetUserEmail()
 {
     return((await _oAuthAppService.GetUserInfo()).Email);
 }