From 5b0d5e0ac6b1042ac75ece9ac1ba545f7dd1002c Mon Sep 17 00:00:00 2001 From: David van der Bokke Date: Mon, 5 Apr 2021 09:40:14 -0700 Subject: [PATCH 1/8] Update batch documentation --- docs/batch.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/batch.md b/docs/batch.md index eae199b..a612633 100644 --- a/docs/batch.md +++ b/docs/batch.md @@ -7,12 +7,12 @@ The JavaScript client library supports batching HTTP requests to make multiple A The JavaScript client library defines an object called `Batch`. You can start by instantiating this object: ```js -var batch = gapi.client.newBatch(); +const batch = gapi.client.newBatch(); ``` ## Adding requests to the batch -Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_params--) method to add individual HTTP requests. The `add` method supports one optional parameter: +Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_params--) method to add individual HTTP requests. Only requests created via [discovery](discovery.md) should be added to a batch. The `add` method supports one optional parameter: @@ -49,19 +49,18 @@ Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_p Example: ```js -var searchRequest = function(name) { - return gapi.client.request({ - 'path': 'plus/v1/people', - 'params': {'query': name} - }); -}; -var searchAlvin = searchRequest('Alvin'); -var searchSimon = searchRequest('Simon'); +const getMe = gapi.client.people.people.get({ + 'resourceName': 'people/me' +}); + +const getYou = gapi.client.people.people.get({ + 'resourceName': 'people/you' +}); // Adding just the request -batch.add(searchAlvin); +batch.add(getMe); // Adding the request with an ID -batch.add(searchSimon, {'id': 'searchSimon'}); +batch.add(getYou, {'id': 'getYou'}); ``` ## Executing a batch From 72b7a3ebae91e725f0c7a487618b2b0c7e552e46 Mon Sep 17 00:00:00 2001 From: David van der Bokke Date: Mon, 5 Apr 2021 09:40:14 -0700 Subject: [PATCH 2/8] Update batch documentation Update batch.md with discovery generated API sample Remove httpBatch.html sample since it is duplicative of batch.md and out of date(plus API does not exist anymore) --- docs/batch.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/batch.md b/docs/batch.md index eae199b..a612633 100644 --- a/docs/batch.md +++ b/docs/batch.md @@ -7,12 +7,12 @@ The JavaScript client library supports batching HTTP requests to make multiple A The JavaScript client library defines an object called `Batch`. You can start by instantiating this object: ```js -var batch = gapi.client.newBatch(); +const batch = gapi.client.newBatch(); ``` ## Adding requests to the batch -Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_params--) method to add individual HTTP requests. The `add` method supports one optional parameter: +Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_params--) method to add individual HTTP requests. Only requests created via [discovery](discovery.md) should be added to a batch. The `add` method supports one optional parameter:
@@ -49,19 +49,18 @@ Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_p Example: ```js -var searchRequest = function(name) { - return gapi.client.request({ - 'path': 'plus/v1/people', - 'params': {'query': name} - }); -}; -var searchAlvin = searchRequest('Alvin'); -var searchSimon = searchRequest('Simon'); +const getMe = gapi.client.people.people.get({ + 'resourceName': 'people/me' +}); + +const getYou = gapi.client.people.people.get({ + 'resourceName': 'people/you' +}); // Adding just the request -batch.add(searchAlvin); +batch.add(getMe); // Adding the request with an ID -batch.add(searchSimon, {'id': 'searchSimon'}); +batch.add(getYou, {'id': 'getYou'}); ``` ## Executing a batch From 8c955154dc578eb880481cfb0a8b38bbdbfba0ba Mon Sep 17 00:00:00 2001 From: Niel Markwick Date: Fri, 25 Feb 2022 12:17:03 +0100 Subject: [PATCH 3/8] Add clarification for Chrome Extensions Manifest v3 GAPI is not supported for Chrome Extensions with Manifest v3 due to the no remotely hosted code requirement. Updated docs to reflect this --- docs/faq.md | 5 +++++ docs/start.md | 2 ++ 2 files changed, 7 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index d04e243..a684f19 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -29,3 +29,8 @@ The JavaScript client library does not directly support logging the user out of Since logging out of the application also logs the user out of the Google account, it is not recommended to log the user out unless the user requests this explicitly. For a workaround that allows your application to log the user out programatically, see [this topic](https://groups.google.com/forum/?fromgroups=#!topic/google-api-javascript-client/PCs8xXV4wxk) in the JavaScript client library discussion group. + + +### Is it possible to use the JavaScript client library in a Chrome Extension? + +Chrome Extensions using Manifest v3 do not allow [remotely hosted code](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-overview/#remotely-hosted-code), so the Javascript client library cannot be used in this case. diff --git a/docs/start.md b/docs/start.md index 4f12aea..9377fb8 100644 --- a/docs/start.md +++ b/docs/start.md @@ -85,6 +85,8 @@ Google APIs support [CORS](http://www.w3.org/TR/cors/). If your application need The JavaScript client library works with the same browsers supported by [Google Apps](https://support.google.com/a/answer/33864) except that mobile browsers are currently not fully supported. It only works within HTML documents with a `` element served using the `https` _(preferred)_ and `http` protocols. However, `