You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,16 +161,16 @@ For detailed instructions, please refer to [https://gist.github.com/tanaikech/eb
161
161
-"Who has access to the app:":**Only myself**
162
162
1.**Situation 2**
163
163
-"Execute the app as:":**Me**
164
-
-"Who has access to the app:":**Anyone**
164
+
-"Who has access to the app:":**Anyonewith Google account**
165
165
1.**Situation 3**
166
166
-"Execute the app as:":**Me**
167
-
-"Who has access to the app:":**Anyone, even anonymous**
167
+
-"Who has access to the app:":**Anyone**
168
168
1.**Situation 4**
169
169
-"Execute the app as:":**User accessing the web app**
170
170
-"Who has access to the app:":**Only myself**
171
171
1.**Situation 5**
172
172
-"Execute the app as:":**User accessing the web app**
173
-
-"Who has access to the app:":**Anyone**
173
+
-"Who has access to the app:":**Anyonewith Google account**
174
174
175
175
# Understanding Access and Interaction
176
176
@@ -321,17 +321,17 @@ For example, in **Situation 5**, the Web App's script runs as each user (both th
321
321
322
322
## Access Token for Accessing Web Apps
323
323
324
-
* When a Web App is deployed with**"`Who has access to the app:` Only myself`"** or **"`Who has access to the app:` Anyone`"** by the owner, both the owner and client users must access and run the Web App's script using their own access token.
324
+
* When a Web App is deployed with**"`Who has access to the app:` Only myself`"** or **"`Who has access to the app: Anyone with Google account`"** by the owner, both the owner and client users must access and run the Web App's script using their own access token.
325
325
* At least one Drive API scope must be included in the access token. Examples include:
* Even if the server script uses scopes other than those for Drive API, these additional scopes are not required to be included in the access token. This is because the use of other scopes is authorized through the browser before accessing the Web App. This means that when making GET or POST requests to the Web App, only Drive API scopes are required.
330
330
* For instance, when accessing a Web App using Google Apps Script, if you use `{"Authorization": "Bearer " + ScriptApp.getOAuthToken()}` in the headers and encounter an `<TITLE>Unauthorized</TITLE>` error, check the scopes defined in your script editor. If `https://www.googleapis.com/auth/drive` is not included, you can add it by, for example, placing `// DriveApp.getFiles()` in your script **as a comment**. The script editor will then automatically include the `https://www.googleapis.com/auth/drive` scope.
331
331
332
-
* If no scopes are used in the Web App's scripts, the owner and client users can run the script without browser-based scope authorization. However, an access token is still required to access the Web App if it's deployed as **"`Who has access to the app:` Only myself`"** or **"`Who has access to the app:` Anyone`"**.
332
+
* If no scopes are used in the Web App's scripts, the owner and client users can run the script without browser-based scope authorization. However, an access token is still required to access the Web App if it's deployed as **"`Who has access to the app:` Only myself`"** or **"`Who has access to the app: Anyone with Google account`"**.
333
333
334
-
* Only when the Web App is deployed as **"`Who has access to the app:` Anyone, even anonymous`"** can the owner and client users access the Web App without an access token.
334
+
* Only when the Web App is deployed as **"`Who has access to the app: Anyone`"** can the owner and client users access the Web App without an access token.
335
335
336
336
---
337
337
@@ -1014,7 +1014,7 @@ const doPost = (e) => {
1014
1014
};
1015
1015
```
1016
1016
1017
-
- This Web App is deployed with `Execute the app as: Me` and `Who has access to the app: Anyone, even anonymous`.
1017
+
- This Web App is deployed with `Execute the app as: Me` and `Who has access to the app: Anyone`.
1018
1018
1019
1019
#### 2. Sample Google Apps Script Project Types
1020
1020
@@ -1065,9 +1065,9 @@ The following table summarizes where logs can be found under different condition
1065
1065
1066
1066
From the above results, the following conclusions were drawn:
1067
1067
1068
-
- If you are using a default Google Apps Script project without linking a GCP project, to retrieve logs from requests to your Web App, you must access the Web App using an access token. This applies even when the Web App is deployed as `Execute the app as: Me` and `Who has access to the app: Anyone, even anonymous`.
1068
+
- If you are using a default Google Apps Script project without linking a GCP project, to retrieve logs from requests to your Web App, you must access the Web App using an access token. This applies even when the Web App is deployed as `Execute the app as: Me` and `Who has access to the app: Anyone`.
1069
1069
1070
-
- If you are using a Google Apps Script project with a linked GCP project, all user access logs to the Web App can be retrieved in Stackdriver. This is true even when the Web App is deployed as `Execute the app as: Me` and `Who has access to the app: Anyone, even anonymous`.
1070
+
- If you are using a Google Apps Script project with a linked GCP project, all user access logs to the Web App can be retrieved in Stackdriver. This is true even when the Web App is deployed as `Execute the app as: Me` and `Who has access to the app: Anyone`.
1071
1071
1072
1072
- In all experimental scenarios, logs generated by `Logger.log` were not visible.
1073
1073
@@ -1085,11 +1085,11 @@ When the error messages are returned from Web Apps, you can see the messages int
1085
1085
1086
1086
| Execute the app as | Who has access to the app | Access | Status code | Error messages | Reason |
| User accessing the web app | Only myself,<br>Anyone | Owner,<br>Users | 200 | Authorization needed | Scopes for scripts of Web Apps are not authorized. |
1089
-
| User accessing the web app,<br>Me | Only myself,<br>Anyone | Owner,<br>Users | 200 | Meet Google Drive 窶・One place for all your files | No access token. |
1088
+
| User accessing the web app | Only myself,<br>Anyone with Google account | Owner,<br>Users | 200 | Authorization needed | Scopes for scripts of Web Apps are not authorized. |
1089
+
| User accessing the web app,<br>Me | Only myself,<br>Anyone with Google account | Owner,<br>Users | 200 | Meet Google Drive 窶・One place for all your files | No access token. |
1090
1090
| For all settings | For all settings | Owner,<br>Users | 200 | Error | "Service invoked too many times in a short time: exec qps. Try Utilities.sleep(1000) between calls." is shown in Body. |
1091
-
| User accessing the web app,<br>Me | Only myself,<br>Anyone | Owner,<br>Users | 401 | Unauthorized | Bad access token.<br>No required scopes. |
1092
-
| User accessing the web app,<br>Me | Anyone | Users | 403 | Google Drive - Access Denied | Project of Web Apps is not shared with users. |
1091
+
| User accessing the web app,<br>Me | Only myself,<br>Anyone with Google account | Owner,<br>Users | 401 | Unauthorized | Bad access token.<br>No required scopes. |
1092
+
| User accessing the web app,<br>Me | Anyone with Google account | Users | 403 | Google Drive - Access Denied | Project of Web Apps is not shared with users. |
1093
1093
| User accessing the web app,<br>Me | Only myself | Users | 404 | Google Drive -- Page Not Found | Users cannot access. |
1094
1094
1095
1095
---
@@ -1102,7 +1102,7 @@ Here, I'll explain the status codes returned from Google Apps Script Web Apps.
1102
1102
1103
1103
### Preparation
1104
1104
1105
-
For this experiment, a Web App was deployed with "Execute the app as"set to `Me` and "Who has access to the app"set to `Anyone, even anonymous`. The sample script for the Web App is as follows:
1105
+
For this experiment, a Web App was deployed with "Execute the app as"set to `Me` and "Who has access to the app"set to `Anyone`. The sample script for the Web App is as follows:
1106
1106
1107
1107
```javascript
1108
1108
functiondoGet(e) {
@@ -1176,7 +1176,7 @@ A status code of `403` was returned. From these results, the following conclusio
1176
1176
1177
1177
One application where this situation is relevant is when registering a webhook with [Trello's REST API](https://developers.trello.com/reference/).
1178
1178
1179
-
When a Web App deployed with "Execute the app as: Me" and "Who has access to the app: Anyone, even anonymous" is registered as a webhook, an error like `{"message":"URL (https://script.google.com/macros/s/###/exec) did not return 200 status code, got 403","error":"ERROR"}` occurs. This error is due to the situation described above.
1179
+
When a Web App deployed with "`Execute the app as: Me`" and "`Who has access to the app: Anyone`" is registered as a webhook, an error like `{"message":"URL (https://script.google.com/macros/s/###/exec) did not return 200 status code, got 403","error":"ERROR"}` occurs. This error is due to the situation described above.
1180
1180
1181
1181
As a workaround for registration, you can use the following flow:
1182
1182
@@ -1185,7 +1185,7 @@ As a workaround for registration, you can use the following flow:
1185
1185
* "Who has access to the app": `Only myself`
1186
1186
* **After retrieving the response** (e.g., `{"id":"###","description":"sample","idModel":"###","callbackURL":"https://script.google.com/macros/s/###/exec","active":true}`), reset the Web App's permissions as follows:
1187
1187
*"Execute the app as": `Me`
1188
-
*"Who has access to the app": `Anyone, even anonymous`
1188
+
*"Who has access to the app": `Anyone`
1189
1189
1190
1190
By following this flow, the webhook can be successfully used.
This section explores **Cross-Origin Resource Sharing (CORS)**in Google Apps Script Web Apps. We'll examine various scenarios where Web Apps are accessed via `GET` and `POST` methods using JavaScript. For these examples, the Web App settings are configured as `Execute the app as: Me` and `Who has access to the app: Anyone, even anonymous`.
1214
+
This section explores **Cross-Origin Resource Sharing (CORS)**in Google Apps Script Web Apps. We'll examine various scenarios where Web Apps are accessed via `GET` and `POST` methods using JavaScript. For these examples, the Web App settings are configured as `Execute the app as: Me` and `Who has access to the app: Anyone`.
1215
1215
1216
1216
The following client-side JavaScript was used for testing:
1217
1217
@@ -2287,7 +2287,7 @@ These are the sample scripts by the various languages for requesting to [Web App
2287
2287
- Setting for Web Apps is as follows.
2288
2288
2289
2289
- **`Execute the app as: Me`**
2290
-
- **`Who has access to the app: Anyone, even anonymous`**
2290
+
- **`Who has access to the app: Anyone`**
2291
2291
- In this settings, no access token is required. When you use other settings, it might be required to use the access token. About this, please check [here](https://github.com/tanaikech/taking-advantage-of-Web-Apps-with-google-apps-script#5-situations-for-web-apps).
0 commit comments