Jakub Hubáček
Jakub Hubáček

Reputation: 71

SpreadsheetApp.getActiveSpreadsheet() ask access to data on Google

I have really simple line of code called from button in menu:

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();

Problem is, this line of code invokes message:

"...needs your permission to access your data on Google"

And that's what makes me sad. I don't want to access data on Google. I just want to edit one sheet of data. This message will confuse all my colegues.

Is there a way how to restrain SpreadsheetApp to use only opened sheet ? How to avoid this message?

Maybe it doesn't look like problem, but saying user that I want to access his data isn't safe practise.

Thanks a lot

Jakub

Upvotes: 2

Views: 1772

Answers (1)

Jakub Hubáček
Jakub Hubáček

Reputation: 71

In the end what saved my day was this comment placed on top:

/**
 * @OnlyCurrentDoc
 */

That invokes message:

View and manage spreadsheets that this application has been installed in

So that's it. More info here: https://developers.google.com/apps-script/guides/services/authorization#manual_authorization_scopes_for_sheets_docs_and_forms

Upvotes: 4

Related Questions