Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dev] Investigate Persistent Connection for GDrive #132

Open
ryanrightmer opened this issue Jan 28, 2021 · 1 comment
Open

[Dev] Investigate Persistent Connection for GDrive #132

ryanrightmer opened this issue Jan 28, 2021 · 1 comment
Assignees

Comments

@ryanrightmer
Copy link
Collaborator

Description

We need to see how we can have our server send data to a google drive without interactive login being required. We want to find out how we can be treated as a service principal, daemon, whatever.

Acceptance Criteria

  • Prototype or really good documentation of how this can work.

Dev Notes

  • We really don't want to hardcode secrets if we can avoid it. But using google secrets manager is probably acceptable

Who should I contact?

@ryanrightmer

Size of Ticket

S

@ryanrightmer
Copy link
Collaborator Author

Here's how we can access files with the the cloud run service account credential. We just need to share the desired folder with the service account compute email address

var credential = GoogleCredential.GetApplicationDefault();
var service = new DriveService(new BaseClientService.Initializer()
{
    HttpClientInitializer = credential,
    ApplicationName = "Drive API .NET Quickstart",
});
// 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;
string returnString = "Files:\n";

if (files != null && files.Count > 0)
{
    foreach (var file in files)
    {
        returnString += $"{file.Name} ({file.Id})";
    }
}
else
{
    returnString = "No files found.";
}
Console.WriteLine(returnString);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant