title: Using Google Sheets API with Node
body: <p>I am trying to load one of my google sheets with node. I am able to get my access tokens from google but when I try and load the sheet I get the error: </p>
  
  <blockquote>
    <p>Error: No access to that spreadsheet, check your auth.spreadsheet</p>
  </blockquote>
  
  <p>Here is my app.js file:</p>
  
  <pre><code>var express = require('express')
  var app = express()
  
  CLIENT_ID = "MY_CLIENT_ID";
  CLIENT_SECRET = "MY_SECRET";
  REDIRECT_URL = "http://127.0.0.1:3000/oauth/callback";
  
  
  var oauth2Client = new OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
  
  var google = require('googleapis');
  var GoogleSpreadsheets = require('google-spreadsheets');
  var oauth2Client = new google.auth.OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
  
  var url = oauth2Client.generateAuthUrl({
    access_type: 'online', 
    scope: 'https://www.googleapis.com/auth/drive' 
  });
  
  app.get('/', function (req, res) {
    res.redirect(url);
    res.send('Hello World');
  });
  
  app.get('/oauth/callback', function (req, res) {
  var code = req.param('code');
  
      GoogleSpreadsheets({
      key: 'MY_SHEET_KEY',
      auth: oauth2Client.getToken(code, function(err, tokens) {
      // Now tokens contains an access_token and an optional refresh_token. Save them.
      if(!err) {
          oauth2Client.setCredentials(tokens);
      }
      console.log(tokens); //this prints my tokens as an array
  })
  }, function(err, spreadsheet) {
      console.log(err + "spreadsheet");
  });
  
  res.send('Hello World');
  });
  
  app.listen(3000)
  </code></pre>