nloomans
nloomans

Reputation: 220

node.js google oauth2 sample stopped working invalid_grant

I'm writing a program that uses the google calendar api, so I used the quick start from here and it worked. but recently the same code stopped working and gave me the following error.

The API returned an error: Error: invalid_grant

This means that the error came from

103: calendar.events.list()

What could cause this problem and how can I fix it?

Upvotes: 4

Views: 2588

Answers (1)

Jeremy Irish
Jeremy Irish

Reputation: 51

This happened to me when I changed my account password. To fix it I had to delete the credentials file that gets referenced in the quick start here:

var SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'];
TOKEN_DIR = (process.env.HOME || process.env.HOMEPATH ||
process.env.USERPROFILE) + '/.credentials/';
var TOKEN_PATH = TOKEN_DIR + 'drive-nodejs-quickstart.json';

This should do the trick.

rm /Users/<username>/.credentials/drive-nodejs-quickstart.json

Upvotes: 5

Related Questions