# agrefab-google-api-client

> NodeJS library for accessing Google APIs.

Latest version **0.0.7** (published 2021-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install agrefab-google-api-client
pnpm add agrefab-google-api-client
yarn add agrefab-google-api-client
bun add agrefab-google-api-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2021-10-05 |
| First published | 2021-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | kevin@agrefab.com |
| Maintainers | natebass |
| Keywords | agrefab |

## Links

- npm: https://www.npmjs.com/package/agrefab-google-api-client
- Repository: https://github.com/agrefabportal/agrefab-google-api-client
- Homepage: https://github.com/agrefabportal/agrefab-google-api-client#readme
- Issues: https://github.com/agrefabportal/agrefab-google-api-client/issues
- npm.io page: https://npm.io/package/agrefab-google-api-client

## Dependencies (1)

- [googleapis](https://npm.io/package/googleapis.md) ^39.2.0

## Recent versions

- 0.0.7 (latest) — 2021-10-05
- 0.0.6 — 2021-10-05
- 0.0.5 — 2021-09-25
- 0.0.4 — 2021-09-23
- 0.0.3 — 2021-09-21
- 0.0.1 — 2021-09-20

## README

# Agrefab Google API Client for NodeJS
NodeJS client for getting data from various Google APIs.

## Installation
`npm i agrefab-google-api-client`

## How to use
```javascript
const GoogleApiClient = require('agrefab-google-api-client');

(async function main() {
    let your_credentials = {
        "web": {
            "client_id": "###REMOVED###",
            "project_id": "###REMOVED###",
            "auth_uri": "https://accounts.google.com/o/oauth2/auth",
            "token_uri": "https://oauth2.googleapis.com/token",
            "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
            "client_secret": "###REMOVED###",
            "redirect_uris": [
                "http://localhost:3000/a"
            ],
            "javascript_origins": [
                "https://awsagrefab.com",
                "http://localhost",
                "http://localhost:3000"
            ]
        }
    };
    let api = new GoogleApiClient(your_credentials);
    let authResult = await api.authorize();
    let data = await api.listExampleData().catch(error => {
        console.log('GOOGLE API RESPONSE ERROR: ' + error);
    });
})().catch(error => console.error(error));
```
See [tests.js](tests.js) for more examples.

## Usage information
* Requires valid token saved at ./tokens.json. You are responsible for using a web server to get this or copy pasting a token from an API explorer into a file at that location.
* You must call api.authrorize() and get a successful response from before making a call to any API.
*  The program needs to be run on a server with a persistent filesystem due to tokens being saved as files.
* You must create your own web OAuth project in Google Cloud console. Make sure to enable all APIs that are used.

### Google APIs used
* Google Sheets

---
_Source: https://npm.io/package/agrefab-google-api-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
