.net - Google.Apis.Requests.RequestError Login Required [401] Message[Login Required] Location -


so downloaded .net client cloud storage nuget (google.apis.storage.v1, version=1.8.1.10), created project using developer console, generated api key, enabled billing, created bucket.
when i'm trying list objects in bucket, i'm getting error (login required). ideas why may be? cloud storage , json api enabled in console.
here's full code sample app: https://gist.github.com/chester89/5d6a62633abab3969c32

an api key simple marker says "this call associated project." useful managing quota, not secret , not authenticate caller particular user. bucket presumably not browsable anonymous callers, , call made anonymously.

you fix granting anonymous users read access bucket, better idea authenticate requests. have several options on how this, depending on whether want make calls own personal credentials or whether want use service account associated application. full instructions documented here: https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth

guessing want authenticate , you're writing application run on desktop, here's example:

usercredential credential; using (var stream = new filestream("client_secrets.json", filemode.open, fileaccess.read)) {    credential = await googlewebauthorizationbroker.authorizeasync(          googleclientsecrets.load(stream).secrets,          new[] { booksservice.scope.books },          "user", cancellationtoken.none, new filedatastore("books.listmylibrary")); } // create service. var service = new booksservice(new baseclientservice.initializer() {    httpclientinitializer = credential,          applicationname = "books api sample", }); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -