cordova-google-oauth2

1.0.0 • Public • Published

cordova-google-oauth2

Installation

Example

import googleOAuth from './googleOAuth.js';

const CLIENT_ID = 'xxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com';
const scriptId = 'yyyyyyy-yyyyyyyyyyyyyyyyyyyyyyyyy';
const sheetId = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
const SCOPES = [
  'https://www.googleapis.com/auth/drive',
  'https://www.googleapis.com/auth/spreadsheets'
];

googleOAuth(CLIENT_ID, SCOPES, {redirect_uri: 'http://localhost/callback'})
.then((response) => {
  if (response.error) {
    console.error(response);
    return;
  }
  return gapi.client.request({
    'root': 'https://script.googleapis.com',
    'path': `v1/scripts/${scriptId}:run`,
    'method': 'POST',
    'body': {
      'function': 'load',
      'parameters': [sheetId]
    }
  });
})
.then((res) => {
  const resp = JSON.parse(res.body);
  console.log(resp.response);
})
.catch((error) => {
  console.error(error);
});

Package Sidebar

Install

npm i cordova-google-oauth2

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

7.33 kB

Total Files

8

Last publish

Collaborators

  • qertis