Skip to content

Conversation

Copy link

Copilot AI commented Dec 17, 2025

Service accounts cannot access Shared Drives restricted to organization members. This adds OAuth 2.0 user credential support alongside existing service account authentication.

Changes

Core API additions:

  • SheetHelper, SheetAppender, SheetExporter:
    • New Init(ICredential) overload accepts any credential type (OAuth UserCredential, ServiceAccountCredential, etc.)
    • New constructor overload (spreadsheetID, tabName) for credentials that don't require service account email

Documentation:

  • Added OAuth 2.0 setup guide with GoogleWebAuthorizationBroker flow
  • Clarified when to use each authentication method

Usage

OAuth 2.0 (new):

UserCredential credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
    GoogleClientSecrets.FromStream(stream).Secrets,
    new[] { SheetsService.Scope.Spreadsheets },
    "user", CancellationToken.None);

var sheetHelper = new SheetHelper<TestRecord>(spreadsheetId, tabName);
sheetHelper.Init(credential);

Service Account (unchanged):

var sheetHelper = new SheetHelper<TestRecord>(spreadsheetId, serviceAccountEmail, tabName);
sheetHelper.Init(jsonCredentials);

All existing service account code continues to work without modification.

Original prompt

This section details on the original issue you should resolve

<issue_title>Alternative authentication methods (to service accounts)</issue_title>
<issue_description>At the moment, we can only authenticate with service accounts.

The problem is that service accounts cannot access Shared Drives because it is restricted to members of the organization / domain.

Is it possible to authenticate via other methods (e.g. user accounts with OAuth)?
</issue_description>

Comments on the Issue (you are @copilot in this section)

@SteveWinward @rohan-gaitonde today this library only supports service account authentication. The native Google Sheets API does support this so it is possible to configure this, just not supported today in the GoogleSheetsWrapper API.

I'm tagging this with the enhancement label so if anyone has the cycles to implement this into this library they can create a pull request for it. </comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@SteveWinward SteveWinward marked this pull request as ready for review December 17, 2025 20:22
Copilot AI and others added 3 commits December 17, 2025 20:25
Co-authored-by: SteveWinward <2002602+SteveWinward@users.noreply.github.com>
Co-authored-by: SteveWinward <2002602+SteveWinward@users.noreply.github.com>
…hods

Co-authored-by: SteveWinward <2002602+SteveWinward@users.noreply.github.com>
Copilot AI changed the title [WIP] Add alternative authentication methods for Google Sheets API Add OAuth 2.0 user authentication support for accessing organization Shared Drives Dec 17, 2025
Copilot AI requested a review from SteveWinward December 17, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alternative authentication methods (to service accounts)

2 participants