Как предоставить учетные данные программно для использования Google Drive API в c # или vb.net?

Я сделал программу, которая использует API Google Drive для чтения данных из файла на Google Drive.

при первом запуске приложения открывается веб-браузер с просьбой войти в систему с учетной записью Google Drive.

Я хочу предоставить приложению имя пользователя и пароль, чтобы оно получало учетные данные автоматически, чтобы пользователям не нужно было знать имя пользователя и пароль моей учетной записи на диске Google.

вот код в vb.net:

    Dim credential As UserCredential

    Using stream = New FileStream("client_secret.json", FileMode.Open, FileAccess.Read)
        Dim credPath As String = System.Environment.GetFolderPath(
            System.Environment.SpecialFolder.Personal)
        credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart.json")

        credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
        GoogleClientSecrets.Load(stream).Secrets,
        Scopes,
        "user",
        CancellationToken.None,
        New FileDataStore(credPath, True)).Result
        'Console.WriteLine("Credential file saved to: " + credPath)
    End Using

    //I want to provide the username and password in the app so that it doesn't open a web browser asking for them

    ' Create Drive API service.
    Dim initializer = New BaseClientService.Initializer
    initializer.HttpClientInitializer = credential
    initializer.ApplicationName = ApplicationName
    Dim service = New DriveService(initializer)

    ' Define parameters of request.
    Dim listRequest As FilesResource.ListRequest = service.Files.List()
    listRequest.PageSize = 10
    listRequest.Fields = "nextPageToken, files(id, name)"

    ' List files.
    Dim files As IList(Of Google.Apis.Drive.v3.Data.File) = listRequest.Execute().Files

Вот код в C #:

        UserCredential credential;

        using (var stream =
            new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
        {
            string credPath = System.Environment.GetFolderPath(
                System.Environment.SpecialFolder.Personal);
            credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart.json");

            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                Scopes,
                "user",
                CancellationToken.None,
                new FileDataStore(credPath, true)).Result;
            //Console.WriteLine("Credential file saved to: " + credPath);
        }

        //I want to provide the username and password in the app so that it doesn't open a web browser asking for them

        // Create Drive API service.
        var service = new DriveService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = ApplicationName,
        });

        // Define parameters of request.
        FilesResource.ListRequest listRequest = service.Files.List();
        listRequest.PageSize = 10;
        listRequest.Fields = "nextPageToken, files(id, name)";

        // List files.
        IList<Google.Apis.Drive.v3.Data.File> files = listRequest.Execute()
            .Files;

Ответы на вопрос(1)

Ваш ответ на вопрос