Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. const functions = require('firebase-functions');
  2.  
  3. // firebase admin
  4. const admin = require('firebase-admin');
  5. admin.initializeApp(functions.config().firebase);
  6.  
  7. // google sheet api
  8. const google = require('googleapis');
  9. const key = require('./key/serviceKey.json');
  10.  
  11. const scopes = [
  12. 'https://www.googleapis.com/auth/spreadsheets',
  13. 'https://www.googleapis.com/auth/drive'
  14. ];
  15.  
  16. const authClient = new google.auth.JWT(
  17. key.client_email, null, key.private_key, scopes, null
  18. );
  19.  
  20. authClient.authorize((err, tokens) => {
  21. if (err) {
  22. console.log('error occurred when authorising with JWT');
  23. } else {
  24. console.log('auth success, tokens', tokens);
  25. google.options({ auth: authClient });
  26. }
  27. });
  28.  
  29. const drive = google.drive('v2');
  30. const sheets = google.sheets('v4');
Add Comment
Please, Sign In to add comment