clasp icon indicating copy to clipboard operation
clasp copied to clipboard

Bug Report: SpreadsheetApp Functionality Failure in clasp 3.0.3-alpha

Open portfolio-y0711 opened this issue 7 months ago • 1 comments

Bug: SpreadsheetApp.getActiveSpreadsheet Fails in clasp 3.0.3-alpha

Summary

The SpreadsheetApp.getActiveSpreadsheet function, executed via clasp run, works correctly in clasp 2.4.3 but fails with a permission error in clasp 3.0.3-alpha.

Environment

  • clasp Version: 3.0.3-alpha
  • Function: SpreadsheetApp.getActiveSpreadsheet
  • Error Message:
    Exception: Error: You do not have permission to call SpreadsheetApp.getActiveSpreadsheet.
    Required permissions: (https://www.googleapis.com/auth/spreadsheets.currentonly || https://www.googleapis.com/auth/spreadsheets) []
    

Steps to Reproduce

  1. Install clasp 3.0.3-alpha globally.
  2. Run a script that calls SpreadsheetApp.getActiveSpreadsheet using clasp run.
  3. Observe the permission error mentioned above.

Expected Behavior

  • The script should execute successfully, as it does in clasp 2.4.3.

Actual Behavior

  • The script fails with the permission error in clasp 3.0.3-alpha.

Comparative Behavior

  • clasp 2.4.3: The same script runs without errors using clasp run.
  • clasp 3.0.3-alpha: Fails due to the permission error.

Workaround

  • Downgrade clasp to version 2.4.3 globally:
    npm install -g @google/[email protected]
    
  • The script then runs successfully.

Additional Notes

  • This issue likely results from changes in permission handling for SpreadsheetApp in clasp 3.0.3-alpha.
  • If unintentional, this represents a regression from previous functionality.
  • The permission scopes acquired by clasp (https://www.googleapis.com/auth/spreadsheets.currentonly or https://www.googleapis.com/auth/spreadsheets) need to be properly handled to ensure functionality.

Request

  • Investigate the cause of the permission error.
  • Restore SpreadsheetApp.getActiveSpreadsheet functionality in clasp 3.0.3-alpha.

Related Issues

  • [Add references to any related issues, if known]

portfolio-y0711 avatar May 10 '25 04:05 portfolio-y0711

Please include the command line that you used.

Likely this is due to changes in auth handling to use named user accounts by default instead of separate global/local files. 3.x doesn't attempt to load the previously authorized local credentials for run.

Adding the option --auth <path_to_clasprc.json> should work. Give that a try, and if so, I'll update the migration instructions

sqrrrl avatar May 10 '25 21:05 sqrrrl

Closing due to lack of follow up

sqrrrl avatar Jul 22 '25 05:07 sqrrrl