danthareja / node-google-apps-script

[DEPRECATED - use clasp instead] The easiest way to develop Google Apps Script projects
MIT License
353 stars 70 forks source link

gapps auth not finding variable tokens #39

Closed WhiteHotLoveTiger closed 7 years ago

WhiteHotLoveTiger commented 8 years ago

Whe I run gapps auth, it gives me a url, I go to the google page, click to allow permissions, and then get an error in the console:

whlt@myUbuntuBox:~$ gapps auth ~/Downloads/client_secret_123456789.apps.googleusercontent.com.json 

Please visit the following url in your browser (you'll only have to do this once): https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.scripts&response_type=code&client_id=123456789.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A2386
/usr/local/lib/node_modules/node-google-apps-script/lib/commands/auth.js:89
        credentials.refresh_token = tokens.refresh_token;
                                          ^

TypeError: Cannot read property 'refresh_token' of undefined
    at /usr/local/lib/node_modules/node-google-apps-script/lib/commands/auth.js:89:43
    at /usr/local/lib/node_modules/node-google-apps-script/node_modules/google-auth-library/lib/auth/oauth2client.js:154:5
    at Request._callback (/usr/local/lib/node_modules/node-google-apps-script/node_modules/google-auth-library/lib/transporters.js:70:30)
    at self.callback (/usr/local/lib/node_modules/node-google-apps-script/node_modules/google-auth-library/node_modules/request/request.js:198:22)
    at emitOne (events.js:77:13)
    at Request.emit (events.js:169:7)
    at Request.onRequestError (/usr/local/lib/node_modules/node-google-apps-script/node_modules/google-auth-library/node_modules/request/request.js:861:8)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at ClientRequest.onError (/usr/local/lib/node_modules/node-google-apps-script/node_modules/tunnel-agent/index.js:178:21)
    at ClientRequest.g (events.js:260:16)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at TLSSocket.socketErrorListener (_http_client.js:258:9)
    at emitOne (events.js:77:13)
    at TLSSocket.emit (events.js:169:7)
whlt@myUbuntuBox:~$ 

My client_secret_blahblah.json looks like this: {"installed":{"client_id":"123456-qwerty987654321.apps.googleusercontent.com","project_id":"project-id-2468101214","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"QwErTy123456","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}

Should I be calling the auth command differently?

WhiteHotLoveTiger commented 8 years ago

https://youtu.be/OBwS66EBUcY

WhiteHotLoveTiger commented 7 years ago

Turns out my problem was occurring because I was behind a proxy. I used a connection outside of my proxy to do the initial authorisation (cell phone hotspot), and now that I'm set up, I can run gapps upload from behind the proxy using the standard unix command line proxy export in my /etc/profile:

export http_proxy="http://proxy.company.com:8080/"
export https_proxy="https://proxy.company.com:8080/"