Firebase Update

This commit is contained in:
Lukas Nowy
2018-12-22 23:30:39 +01:00
parent befb44764d
commit acffe619b3
11523 changed files with 1614327 additions and 930246 deletions

View File

@ -3,7 +3,6 @@
# Google Auth Library
[![npm version][npmimg]][npm]
[![CircleCI][circle-image]][circle-url]
[![codecov][codecov-image]][codecov-url]
[![Dependencies][david-dm-img]][david-dm]
[![Known Vulnerabilities][snyk-image]][snyk-url]
@ -17,9 +16,6 @@ This library is distributed on `npm`. To add it as a dependency, run the followi
$ npm install google-auth-library
```
## Upgrading to 1.x
The `1.x` release includes a variety of bug fixes, new features, and breaking changes. Please take care, and see [the release notes](https://github.com/google/google-auth-library-nodejs/releases/tag/v1.0.0) for a list of breaking changes, and the upgrade guide.
## Ways to authenticate
This library provides a variety of ways to authenticate to your Google services.
- [Application Default Credentials](#choosing-the-correct-credential-type-automatically) - Use Application Default Credentials when you use a single identity for all users in your application. Especially useful for applications running on Google Cloud.
@ -34,7 +30,7 @@ They are best suited for cases when the call needs to have the same identity and
#### Download your Service Account Credentials JSON file
To use `Application Default Credentials`, You first need to download a set of JSON credentials for your project. Go to **APIs & Auth** > **Credentials** in the [Google Developers Console][devconsole] and select **Service account** from the **Add credentials** dropdown.
To use Application Default Credentials, You first need to download a set of JSON credentials for your project. Go to **APIs & Auth** > **Credentials** in the [Google Developers Console][devconsole] and select **Service account** from the **Add credentials** dropdown.
> This file is your *only copy* of these credentials. It should never be
> committed with your source code, and should be stored securely.
@ -161,7 +157,7 @@ main();
```
#### Handling token events
This library will automatically obtain an `access_token`, and automatically refresh the `access_token` if a `refresh_token` is present. The `refresh_token` is only returned on the [first authorization](https://github.com/google/google-api-nodejs-client/issues/750#issuecomment-304521450), so if you want to make sure you store it safely. An easy way to make sure you always store the most recent tokens is to use the `tokens` event:
This library will automatically obtain an `access_token`, and automatically refresh the `access_token` if a `refresh_token` is present. The `refresh_token` is only returned on the [first authorization](https://github.com/googleapis/google-api-nodejs-client/issues/750#issuecomment-304521450), so if you want to make sure you store it safely. An easy way to make sure you always store the most recent tokens is to use the `tokens` event:
```js
const client = await auth.getClient();
@ -220,7 +216,7 @@ original scopes, or audience for the token. To get the token info, you can use
```js
// after acquiring an oAuth2Client...
const tokenInfo = await oAuth2client.getTokenInfo('my-access-token');
const tokenInfo = await oAuth2Client.getTokenInfo('my-access-token');
// take a look at the scopes originally provisioned for the access token
console.log(tokenInfo.scopes);
@ -255,14 +251,12 @@ async function main() {
keys.private_key,
['https://www.googleapis.com/auth/cloud-platform'],
);
await client.authorize();
const url = `https://www.googleapis.com/dns/v1/projects/${keys.project_id}`;
const res = await client.request({url});
console.log(res.data);
}
main().catch(console.error);
```
The parameters for the JWT auth client including how to use it with a `.pem` file are explained in [samples/jwt.js](samples/jwt.js).
@ -302,7 +296,6 @@ async function main() {
// load the JWT or UserRefreshClient from the keys
const client = auth.fromJSON(keys);
client.scopes = ['https://www.googleapis.com/auth/cloud-platform'];
await client.authorize();
const url = `https://www.googleapis.com/dns/v1/projects/${keys.project_id}`;
const res = await client.request({url});
console.log(res.data);
@ -349,30 +342,23 @@ See [CONTRIBUTING][contributing].
This library is licensed under Apache 2.0. Full license text is available in [LICENSE][copying].
[Application Default Credentials]: https://developers.google.com/identity/protocols/application-default-credentials#callingnode
[Application Default Credentials]: https://cloud.google.com/docs/authentication/getting-started
[apptype]: https://user-images.githubusercontent.com/534619/36553844-3f9a863c-17b2-11e8-904a-29f6cd5f807a.png
[authdocs]: https://developers.google.com/accounts/docs/OAuth2Login
[axios]: https://github.com/axios/axios
[axiosOpts]: https://github.com/axios/axios#request-config
[bugs]: https://github.com/google/google-auth-library-nodejs/issues
[circle-image]: https://circleci.com/gh/google/google-auth-library-nodejs.svg?style=svg
[circle-url]: https://circleci.com/gh/google/google-auth-library-nodejs
[codecov-image]: https://codecov.io/gh/google/google-auth-library-nodejs/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/google/google-auth-library-nodejs
[contributing]: https://github.com/google/google-auth-library-nodejs/blob/master/.github/CONTRIBUTING.md
[copying]: https://github.com/google/google-auth-library-nodejs/tree/master/LICENSE
[david-dm-img]: https://david-dm.org/google/google-auth-library-nodejs/status.svg
[david-dm]: https://david-dm.org/google/google-auth-library-nodejs
[bugs]: https://github.com/googleapis/google-auth-library-nodejs/issues
[codecov-image]: https://codecov.io/gh/googleapis/google-auth-library-nodejs/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/googleapis/google-auth-library-nodejs
[contributing]: https://github.com/googleapis/google-auth-library-nodejs/blob/master/.github/CONTRIBUTING.md
[copying]: https://github.com/googleapis/google-auth-library-nodejs/tree/master/LICENSE
[david-dm-img]: https://david-dm.org/googleapis/google-auth-library-nodejs/status.svg
[david-dm]: https://david-dm.org/googleapis/google-auth-library-nodejs
[node]: http://nodejs.org/
[npmimg]: https://img.shields.io/npm/v/google-auth-library.svg
[npm]: https://www.npmjs.org/package/google-auth-library
[oauth]: https://developers.google.com/identity/protocols/OAuth2
[snyk-image]: https://snyk.io/test/github/google/google-auth-library-nodejs/badge.svg
[snyk-url]: https://snyk.io/test/github/google/google-auth-library-nodejs
[stability]: http://nodejs.org/api/stream.html#stream_stream
[snyk-image]: https://snyk.io/test/github/googleapis/google-auth-library-nodejs/badge.svg
[snyk-url]: https://snyk.io/test/github/googleapis/google-auth-library-nodejs
[stackoverflow]: http://stackoverflow.com/questions/tagged/google-auth-library-nodejs
[stream]: http://nodejs.org/api/stream.html#stream_class_stream_readable
[devconsole]: https://console.developer.google.com
[options]: https://github.com/google/google-auth-library-nodejs/tree/master#options
[gcloud]: https://github.com/GoogleCloudPlatform/gcloud-node
[cloudplatform]: https://developers.google.com/cloud/