lesander / magister-calendar

:date: Automatically plan your Magister appointments in your Google calendar.
https://git.io/magister
MIT License
11 stars 6 forks source link

Invalid Callback #41

Open CemreSuler opened 6 years ago

CemreSuler commented 6 years ago

Hello,

I am trying to setup the magister calendar, but I can't get it to work, here is my terminal log:

$ node firstrun.js Authorize this app by visiting this url: https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar&response_type=code&client_id=267517455031-t0k1j4afk0horg2fnf86sl0sns42ij5o.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%2Fcallback Enter the code from that page here: MY CODE! fs.js:127 throw new ERR_INVALID_CALLBACK(); ^ TypeError [ERR_INVALID_CALLBACK]: Callback must be a function at maybeCallback (fs.js:127:9) at Object.writeFile (fs.js:1123:14) at storeToken (/Users/Koray/Desktop/magister-calendar-master/firstrun.js:136:6) at /Users/Koray/Desktop/magister-calendar-master/firstrun.js:116:7 at /Users/Koray/Desktop/magister-calendar-master/node_modules/google-auth-library/lib/auth/oauth2client.js:154:5 at Request._callback (/Users/Koray/Desktop/magister-calendar-master/node_modules/google-auth-library/lib/transporters.js:106:7) at Request.self.callback (/Users/Koray/Desktop/magister-calendar-master/node_modules/google-auth-library/node_modules/request/request.js:187:22) at Request.emit (events.js:182:13) at Request. (/Users/Koray/Desktop/magister-calendar-master/node_modules/google-auth-library/node_modules/request/request.js:1044:10) at Request.emit (events.js:182:13)

Thanks for your help!

jvdoorn commented 5 years ago

Hey there!

I just tried it myself, I think Google changed something regarding the way authentication codes are given. I'll get back to you regarding the issue once I've figured out what's going on!

jvdoorn commented 5 years ago

Alright, I found the issue (didn't have anything to do with Google, sorry Google if you see this, I'll never doubt you again). The problem had something to do with fs.js. They changed one of their functions to require a callback.

There are two things you can do:

  1. Check out my fork of this repository (here) and clone that one (I don't have write access to this repository and @lesander hasn't approved my pull requests). Clone it instead of this repository and then follow all the other steps (they don't change). My fork contains a couple improvements, such as being able to change course titles if your school uses abbrevations.
  2. Edit the file yourself. Open firstrun.js and go to line 136 and change .writeFile into .writeFileSync.
lesander commented 5 years ago

Thank you @Argetan. Once your changes are merged this issue is indeed fixed.

CemreSuler commented 5 years ago

I did that, but now I get "invalid request" when running magistercalendar.js

jvdoorn commented 5 years ago

Could you share the full log file? And to be clear, did you check out my repository or did you change the line manually?

P.s. to easily create the log file you can do something of the following: node firstrun.js > output.txt This will create a file output.txt with the output of firstrun.js (replace node firstrun.js with something else if you are running another command of course).

Gusted commented 5 years ago

39 Has the issue too solved