I am trying to connect to Google Cloud Storage using C#
with the .NET on Google Cloud Platform
So I logged into API & Services in Google Then clicked on "Credentials" and Created a new credential. That process gave me a json file similar to the below info.
I tried to connect but keep getting the following error
GoogleApiException: Google.Apis.Requests.RequestError
Not Found [404]
Errors [
Message[Not Found] Location[ - ] Reason[notFound] Domain[global]
]
I used the following code to connect.
string json = "{
\"type\": \"service_account\",
\"project_id\": \"proud-will-228718\",
\"private_key_id\": \"fdgdfgdfgdfgdfgdg\",
\"private_key\": \"private key\",
\"client_email\": \"email address\",
\"client_id\": \"clientid\",
\"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",
\"token_uri\": \"https://oauth2.googleapis.com/token\",
\"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",
\"client_x509_cert_url\": \"cert\"
}";
GoogleCredential credential = GoogleCredential.FromJson(json);
var storage = StorageClient.Create(credential);
var options = new ListObjectsOptions() { Delimiter = delimiter };
foreach (var storageObject in storage.ListObjects(
bucketName, prefix, options))
{
Console.WriteLine(storageObject.Name);
}
How can I correctly access Google Cloud storage bucket to get object information?
Also, how can I generate a token or username/password instead of having to log with that above json file?