Skip to content
Advertisement

Is it possible to pass the google api client object to a function?

I have got the following authentication function:

JavaScript

and the following Google Classroom function

JavaScript

Running it like

JavaScript

Whenever I run this, I get error 401, that I don’t have the authentication credential. The problem with this is that I do, and in the case of the program written in only one function, it somehow works. I might end up combining all functions even if it’s messy but I would like to know why this is happening anyway.

Advertisement

Answer

You’re correct in your assumption and your code appears to be fine (and you should try to not mash everything into a single function).

Given your statement, that it works as a single function, I suspect (!?) that what you’re presenting as the code in your question is incorrect.

When you say “Running it like”, is the print statement part of the process, i.e.:

JavaScript

Or perhaps as part of main:

JavaScript

Both of these configurations will (!) work.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement