0

I am writing a .Net code to populate Google sheets from console application.

Reference article https://www.hardworkingnerd.com/how-to-read-and-write-to-google-sheets-with-c/

I understand that we should give access to the service account.

In my organization, I could not share it with the service account and i am hitting the below error.

Sorry, an item cannot be shared outside of [Company]

Is there a way to access/read/write the Google sheets via my own account

Any help on this (.net code) using own account instead of service account will be much appreciated.

Sam
  • 1
  • 1

1 Answers1

0

Your console application needs to provide credentials that authenticate it, and allow asking for consent from the user (you) for the scopes permitted for that app.

This means, when your application makes a request to the Sheets API, it provides its credentials, and if allowed, the API will redirect the user to the app's consent screen, When consent is given to the application, it is able to perform requests in the name of the user.

The service account is an account that can impersonate a user in the domain, only if it was given domain-wide-authorization. Otherwise it can only access application data (data belonging to your own application).

So if you want an application to access user data, then it (the app) must have valid credentials, for the enabled scopes of the enabled APIs.

You can get OAuth 2.0 Client IDs credentials for your app by following the first 4 steps of this answer and use those instead of the service account credentials.


References:

Aerials
  • 4,231
  • 1
  • 16
  • 20