Google Script ~ How to import Google Sheet data from another users spreadsheet?
up vote
0
down vote
favorite
Apologies in advance for the greenness of this question. But I've been digging through Google's documentation and I can't seem to find an example or explanation for exactly what I'm trying to accomplish. Any help would be greatly appreciated at this point.
~~~ EXPLANATION
I'm writing a stand alone app in Google Script, and I also have a Google Sheet which stores data for that script. The script runs as though executed by the user running it, not as though executed by the owner of the script (myself).
From Google Script main window > Publish > Deploy as web app > Execute app as [user accessing the web app]
In order to access the original spreadsheet which is in my Google Drive, I can't just use Google Scripts
SpreadsheetApp.openById(spreadsheetID);
because person running the app doesn't have the sheet in their Google drive. It's in mine. So I need to use an API call to my Google Sheet, in order to allow the user to access the sheets data. What I have so far is this:
var sheetURL = "https://sheets.googleapis.com/v4/spreadsheets/{sheetID}";
var response = UrlFetchApp.fetch(sheetURL, {muteHttpExceptions: true});
~~~ QUESTIONS
Setting "muteHttpExceptions: false" reveals that I didn't provide an API key. So:
1) How do I get said api key, and can I set the permissions scope of it to read only? given that it's going to be visible to the user.
2) Does this require registering the app with Google, in order to get OAuth set up?
3) Ultimately, what should the api call code end up looking like in the Google Script?
api google-apps-script google-sheets
add a comment |
up vote
0
down vote
favorite
Apologies in advance for the greenness of this question. But I've been digging through Google's documentation and I can't seem to find an example or explanation for exactly what I'm trying to accomplish. Any help would be greatly appreciated at this point.
~~~ EXPLANATION
I'm writing a stand alone app in Google Script, and I also have a Google Sheet which stores data for that script. The script runs as though executed by the user running it, not as though executed by the owner of the script (myself).
From Google Script main window > Publish > Deploy as web app > Execute app as [user accessing the web app]
In order to access the original spreadsheet which is in my Google Drive, I can't just use Google Scripts
SpreadsheetApp.openById(spreadsheetID);
because person running the app doesn't have the sheet in their Google drive. It's in mine. So I need to use an API call to my Google Sheet, in order to allow the user to access the sheets data. What I have so far is this:
var sheetURL = "https://sheets.googleapis.com/v4/spreadsheets/{sheetID}";
var response = UrlFetchApp.fetch(sheetURL, {muteHttpExceptions: true});
~~~ QUESTIONS
Setting "muteHttpExceptions: false" reveals that I didn't provide an API key. So:
1) How do I get said api key, and can I set the permissions scope of it to read only? given that it's going to be visible to the user.
2) Does this require registering the app with Google, in order to get OAuth set up?
3) Ultimately, what should the api call code end up looking like in the Google Script?
api google-apps-script google-sheets
developers.google.com/sheets/api/guides/authorizing
– TheMaster
Nov 20 at 11:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Apologies in advance for the greenness of this question. But I've been digging through Google's documentation and I can't seem to find an example or explanation for exactly what I'm trying to accomplish. Any help would be greatly appreciated at this point.
~~~ EXPLANATION
I'm writing a stand alone app in Google Script, and I also have a Google Sheet which stores data for that script. The script runs as though executed by the user running it, not as though executed by the owner of the script (myself).
From Google Script main window > Publish > Deploy as web app > Execute app as [user accessing the web app]
In order to access the original spreadsheet which is in my Google Drive, I can't just use Google Scripts
SpreadsheetApp.openById(spreadsheetID);
because person running the app doesn't have the sheet in their Google drive. It's in mine. So I need to use an API call to my Google Sheet, in order to allow the user to access the sheets data. What I have so far is this:
var sheetURL = "https://sheets.googleapis.com/v4/spreadsheets/{sheetID}";
var response = UrlFetchApp.fetch(sheetURL, {muteHttpExceptions: true});
~~~ QUESTIONS
Setting "muteHttpExceptions: false" reveals that I didn't provide an API key. So:
1) How do I get said api key, and can I set the permissions scope of it to read only? given that it's going to be visible to the user.
2) Does this require registering the app with Google, in order to get OAuth set up?
3) Ultimately, what should the api call code end up looking like in the Google Script?
api google-apps-script google-sheets
Apologies in advance for the greenness of this question. But I've been digging through Google's documentation and I can't seem to find an example or explanation for exactly what I'm trying to accomplish. Any help would be greatly appreciated at this point.
~~~ EXPLANATION
I'm writing a stand alone app in Google Script, and I also have a Google Sheet which stores data for that script. The script runs as though executed by the user running it, not as though executed by the owner of the script (myself).
From Google Script main window > Publish > Deploy as web app > Execute app as [user accessing the web app]
In order to access the original spreadsheet which is in my Google Drive, I can't just use Google Scripts
SpreadsheetApp.openById(spreadsheetID);
because person running the app doesn't have the sheet in their Google drive. It's in mine. So I need to use an API call to my Google Sheet, in order to allow the user to access the sheets data. What I have so far is this:
var sheetURL = "https://sheets.googleapis.com/v4/spreadsheets/{sheetID}";
var response = UrlFetchApp.fetch(sheetURL, {muteHttpExceptions: true});
~~~ QUESTIONS
Setting "muteHttpExceptions: false" reveals that I didn't provide an API key. So:
1) How do I get said api key, and can I set the permissions scope of it to read only? given that it's going to be visible to the user.
2) Does this require registering the app with Google, in order to get OAuth set up?
3) Ultimately, what should the api call code end up looking like in the Google Script?
api google-apps-script google-sheets
api google-apps-script google-sheets
edited Nov 20 at 9:10
asked Nov 20 at 9:04
RobotMonkeyHead
62
62
developers.google.com/sheets/api/guides/authorizing
– TheMaster
Nov 20 at 11:20
add a comment |
developers.google.com/sheets/api/guides/authorizing
– TheMaster
Nov 20 at 11:20
developers.google.com/sheets/api/guides/authorizing
– TheMaster
Nov 20 at 11:20
developers.google.com/sheets/api/guides/authorizing
– TheMaster
Nov 20 at 11:20
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389504%2fgoogle-script-how-to-import-google-sheet-data-from-another-users-spreadsheet%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
developers.google.com/sheets/api/guides/authorizing
– TheMaster
Nov 20 at 11:20