diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..1aed3a5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,25 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +*Important gapi.auth2 notice*: gapi.auth2 has been deprecated and replaced with Google Identity Services. Please see https://developers.google.com/identity/sign-in/web/deprecation-and-sunset for more information. If you have questions related to authentication/authorization please look at the associated documentation or post questions on Stack Overflow with the google-oauth tag. + +**Summary** +Describe your issue here. + +**Browser(s)/Version(s)** +List browsers and versions affected + +**Expected Behavior** +Tell us what should happen. + +**Actual Behavior** +Tell us what actually happened. + +**Steps to Reproduce** +Please include steps and code samples to aid in issue reproduction(html/javascript). diff --git a/README.md b/README.md index 2719fe6..ea482ed 100644 --- a/README.md +++ b/README.md @@ -2,27 +2,31 @@ ## Description -Written by Google, this compact and efficient client library provides access to Google REST APIs. See below for a list of supported APIs. +The Google API Client Library for JavaScript is designed for JavaScript client-application +developers. It offers simple, flexible access to many Google APIs. -## Beta - -This library is in Beta. We're comfortable enough with the stability and features of the library that we want you to build real production applications on it. We will make an effort to support the public and protected surface of the library and maintain backwards compatibility in the future. While we are still in Beta, we reserve the right to make incompatible changes. If we do remove some functionality (typically because better functionality exists or if the feature proved infeasible), our intention is to deprecate and provide ample time for developers to update their code. +> Note: This repo does not contain the source code for the `gapi` client. ## Features The JavaScript client library [supports these Google APIs](https://developers.google.com/apis-explorer/#p/). -The library supports [OAuth 2 authentication](https://developers.google.com/api-client-library/javascript/features/authentication). +If you use TypeScript, you can install [`@types/gapi`](https://www.npmjs.com/package/@types/gapi) for autocompletion. + +# Documentation + +- [Getting Started](docs/start.md) +- [Reference](docs/reference.md) -## Documentation - - - [Getting Started](https://developers.google.com/api-client-library/javascript/start/start-js) - - [Reference Docs](https://developers.google.com/api-client-library/javascript/reference/referencedocs) - - [Samples](https://developers.google.com/api-client-library/javascript/samples/samples) - - [Support](https://developers.google.com/api-client-library/javascript/help/support) +## Guides + +- [Auth](docs/auth.md) +- [Batch](docs/batch.md) +- [Discovery Documents](docs/discovery.md) +- [FAQ](docs/faq.md) +- [Promises](docs/promises.md) +- [Samples](docs/samples.md) ## Links - - Blogs - - [Announcements](http://google-api-javascript-client.blogspot.com/) - - Groups - - [Discuss](http://groups.google.com/group/google-api-javascript-client) + +- [Discussions](https://github.com/google/google-api-javascript-client/issues) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..0d5d2b9 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,16 @@ +# Google API Client LIbrary for Javascript Docs + + The Google API Client Library for JavaScript is designed for JavaScript +client-application developers. It offers simple, flexible +access to many Google APIs. + +# Documentation + +- [Getting Started](start.md) +- [Auth](auth.md) +- [Batch](batch.md) +- [Discovery Documents](discovery.md) +- [FAQ](faq.md) +- [Promises](promises.md) +- [Reference](reference.md) +- [Samples](samples.md) \ No newline at end of file diff --git a/docs/auth.md b/docs/auth.md new file mode 100644 index 0000000..5e687bc --- /dev/null +++ b/docs/auth.md @@ -0,0 +1,3 @@ +# Authentication + +gapi.auth2 has been deprecated and replaced with Google Identity Services. Please see https://developers.google.com/identity/sign-in/web/deprecation-and-sunset for more information. If you have questions related to authentication/authorization please look at the associated documentation or post questions on Stack Overflow with the google-oauth tag. diff --git a/docs/batch.md b/docs/batch.md new file mode 100644 index 0000000..a612633 --- /dev/null +++ b/docs/batch.md @@ -0,0 +1,78 @@ +# Making Batch Requests + +The JavaScript client library supports batching HTTP requests to make multiple API calls in one round-trip. For reference documentation about batch-related methods and classes, see [Methods and Classes](reference.md#batch-api-requests) + +## Creating a batch + +The JavaScript client library defines an object called `Batch`. You can start by instantiating this object: + +```js +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. Only requests created via [discovery](discovery.md) should be added to a batch. The `add` method supports one optional parameter: + +
| + Param + | ++ Type + | ++ Description + | +
|---|---|---|
+ id
+ |
+ + string + | ++ If an ID is supplied, the API attaches it to the + response to this request. If no ID is supplied, the API + generates a random ID. + | +
| + Parameter + | ++ Type + | ++ Description + | +
|---|---|---|
+ opt_onFulfilled(response)
+ |
+ + function + | ++ Optional fulfilled promise handler. + | +
+ opt_onRejected(reason)
+ |
+ + function + | ++ Optional rejected promise handler. + | +
+ opt_context
+ |
+ + object + | ++ Optional context for the handlers to execute in. + | +
| + Name + | ++ Type + | ++ Description + | +||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ response | reason
+ |
+ + object + | +
+ An object containing information about the HTTP response.
+
|
+
+ This page documents all the methods and classes defined in + the JavaScript client library. +
+gapi.load(libraries, callbackOrConfig)
+
+
+ Asynchronously loads the gapi libraries requested. Use this method to load the
+ gapi.client library.
+
+ Arguments: +
+| + Name + | ++ Type + | ++ Description + | +|||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ libraries
+ |
+ + string + | +
+ A colon (:) separated list of gapi libraries. Ex:
+ "client:iframes".
+ |
+ |||||||||||||||
+ callbackOrConfig
+ |
+ + function|object + | +
+ Either:
+
|
+
+ Example: +
+gapi.load('client', {
+callback: function() {
+// Handle gapi.client initialization.
+initGapiClient();
+},
+onerror: function() {
+// Handle loading error.
+alert('gapi.client failed to load!');
+},
+timeout: 5000, // 5 seconds.
+ontimeout: function() {
+// Handle timeout.
+alert('gapi.client could not load in a timely manner!');
+}
+});
+gapi.client.init(args)
+ + Initializes the JavaScript client with API key, OAuth client ID, scope, and + API discovery document(s). +
++ Arguments: +
+| + Name + | ++ Type + | ++ Description + | +|||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ args
+ |
+ + object + | +
+ An object encapsulating the various arguments for this
+ method. Every argument is optional.
+
|
+
+ Returns: +
+| + Type + | ++ Description + | +|
|---|---|---|
+
+ goog.Thenable
+ |
+
+ The return value is a Promise-like
+
+ goog.Thenable
+ object that resolves when all initializations, including setting the API key, loading
+ discovery documents, and initializing auth, are done.
+ |
+ |
gapi.client.load(urlOrObject)
+
+ Loads the client library interface to a particular API with
+ discovery document
+ URL or JSON object. Returns a Promise-like
+
+ goog.Thenable
+ object that resolves when the API interface is loaded. The loaded API interface will be in
+ the form
+ gapi.client.api.collection.method. For example, the Moderator
+ API would create methods like
+ gapi.client.moderator.series.list.
+
+ Arguments: +
+| + Name + | ++ Type + | ++ Description + | +||
|---|---|---|---|---|
+ urlOrObject
+ |
+ + string | object + | ++ The Discovery Document URL or parsed Discovery Document JSON object + (Example). + | +||
+ Returns: +
+| + Type + | ++ Description + | +|
|---|---|---|
+
+ goog.Thenable
+ |
+
+ The return value is a Promise-like
+
+ goog.Thenable object that resolves when the API interface is loaded.
+ |
+ |
gapi.client.load(name,
+ version,
+ callback)
+
+ Deprecated. Please load APIs with discovery documents.
+ Loads the client library interface to a particular API. If a callback is not provided, a
+
+ goog.Thenable is returned. The loaded API interface will be in the form
+ gapi.client.api.collection.method. For example, the Moderator
+ API would create methods like
+ gapi.client.moderator.series.list.
+
+ Arguments: +
+| + Name + | ++ Type + | ++ Description + | +||
|---|---|---|---|---|
+ name
+ |
+ + string + | ++ The name of the API to load. + | +||
+ version
+ |
+ + string + | ++ The version of the API to load. + | +||
+ callback
+ |
+ + function + | +
+ (optional) the function that is called once the API
+ interface is loaded. If not provided, a
+
+ goog.Thenable is returned.
+ |
+ ||
gapi.client.setApiKey(apiKey)
+ + Sets the API key for the application, which can be found in + the Developer Console. Some APIs require this to be set in + order to work. +
++ Arguments: +
+| + Name + | ++ Type + | ++ Description + | +||
|---|---|---|---|---|
+ apiKey
+ |
+ + string + | ++ The API key to set. + | +||
gapi.client.setToken(tokenObject)
+ + Sets the authentication token to use in requests. +
++ Arguments: +
+| + Name + | ++ Type + | ++ Description + | +||||||
|---|---|---|---|---|---|---|---|---|
+ tokenObject
+ |
+ + object + | +
+ An object containing the access_token to use in API requests.
+
|
+
gapi.client.request(args)
+ + Creates a HTTP request for making RESTful requests. +
++ Arguments: +
+| + Name + | ++ Type + | ++ Description + | +||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ args
+ |
+ + object + | +
+ An object encapsulating the various arguments for this
+ method. The path is required, the rest are optional.
+ The values are described in detail below.
+
|
+
+ Returns: +
+| + Type + | ++ Description + | +|
|---|---|---|
+ gapi.client.Request | undefined
+ |
+
+ The returned gapi.client.Request object implements
+
+ goog.Thenable and can be used like a Promise that
+ fulfills with the response object or rejects with a reason object.
+ |
+ |
+ An object encapsulating an HTTP request. This object is not
+ instantiated directly, rather it is returned by gapi.client.request.
+ There are two ways to execute a request. We recommend that you treat the object as a promise
+ and use the then method, but you can also use the execute method
+ and pass in a callback.
+
gapi.client.Request.then(onFulfilled, onRejected, context)
+ + For more information about using promises, see + Using Promises. +
+gapi.client.Request.execute(callback)
+ + Executes the request and runs the supplied callback on + response. +
++ Arguments: +
+| + Name + | ++ Type + | ++ Description + | +||
|---|---|---|---|---|
+ callback(jsonResp,rawResp)
+ |
+ + function + | +
+ The callback function which executes when the request
+ succeeds or fails. jsonResp contains the
+ response parsed as JSON. If the response is not JSON,
+ this field will be false.
+ rawResp is the HTTP response. It is JSON,
+ and can be parsed to an object which includes
+ body, headers,
+ status, and statusText
+ fields.
+ |
+ ||
gapi.client.newBatch()
+ + Creates a batch object for batching individual requests. +
++ Returns: +
+| + Type + | ++ Description + | +|
|---|---|---|
+ gapi.client.Batch | undefined
+ |
+
+ The returned gapi.client.Batch implements
+
+ goog.Thenable interface and can be used like a Promise that fulfills with
+ a batch response object and rejects with a reason object.
+ |
+ |
+ Represents an HTTP Batch operation. Individual HTTP requests are
+ added with the add method and the batch can be
+ executed using then or execute. We recommend that you treat the
+ batch object as a promise and use then. This class defines the following
+ methods:
+
gapi.client.Batch.add(request,opt_params)
+
+ Adds a gapi.client.Request to the batch.
+
+ Arguments: +
+| + Name + | ++ Type + | ++ Description + | +|||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ request
+ |
+ + gapi.client.Request + | ++ The HTTP request to add to this batch. This parameter is + required. + | +|||||||||||
+ opt_params
+ |
+ + Object + | +
+ Optional extra parameters for this batch entry.
+ Accepted fields are id and
+ callback:
+
|
+ |||||||||||
gapi.client.Batch.then(onFulfilled, onRejected, context)
+ + For more information about using promises, see + Using Promises. +
+gapi.client.Batch.execute(callback)
+ + Executes all requests in the batch. The supplied callback + is executed on success or failure. +
+| + Name + | ++ Type + | ++ Description + | +
|---|---|---|
+ callback(responseMap,
+ rawBatchResponse)
+ |
+ + function + | +
+ The callback to execute when the batch returns.
+ responseMap is an ID-response map of each
+ requests response. rawBatchResponse is the
+ same response, but as an unparsed JSON-string.
+ |
+