gee-community / ee-runner

Command-line runner for Google Earth Engine Playground scripts
Apache License 2.0
67 stars 18 forks source link

TypeError: Cannot read property 'access_token' of null #12

Closed johnniehard closed 6 years ago

johnniehard commented 6 years ago

First, cleanup:

$ rm ~/.config/earthengine/credentials

Then run example script:

$ node ee-runner.js examples/hello.js
If browser does not open, use the following URL to get access code:
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fearthengine.readonly&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=517222506229-vsmmajv00ul0bs7p89v5m89qs8eb9359.apps.googleusercontent.com

Please enter authorization code: 
[auth code]
Entered code: [auth code]

[long url containg my auth]
Running script: /home/johnnie/tmp/ee-runner/examples/hello.js
First image in LANDSAT 8 TOA collection was aquired on 2014-03-21
Downloading thumbnail ...
https://earthengine.googleapis.com/api/thumb?thumbid=0f73e2a68018e8be5b5c44e776a1c3eb&token=[token that may be supposed to be private?]

At this point the script stops and nothing happens until I press Enter, which gives this:

Entered code:

[url containing auth]
/home/johnnie/tmp/ee-runner/authenticate.js:27
            ee.data.authToken_ = 'Bearer ' + tokens['access_token'];
                                                   ^

TypeError: Cannot read property 'access_token' of null
    at /home/johnnie/tmp/ee-runner/authenticate.js:27:52
    at OAuth2Client.refreshAccessToken (/home/johnnie/tmp/ee-runner/node_modules/google-auth-library/lib/auth/oauth2client.js:199:5)
    at init (/home/johnnie/tmp/ee-runner/authenticate.js:26:16)
    at Request.optionalCallback [as _callback] (/home/johnnie/tmp/ee-runner/authenticate.js:94:17)
    at Request.self.callback (/home/johnnie/tmp/ee-runner/node_modules/request/request.js:197:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:194:7)
    at Request.<anonymous> (/home/johnnie/tmp/ee-runner/node_modules/request/request.js:1050:14)
    at emitOne (events.js:101:20)
    at Request.emit (events.js:191:7)

The weird thing here is that the image does download this first time I run the script after clearing the credentials, despite the hangup and error. Running the script again only gives the error, no image is downloaded.

No credentials get written to the credentials file:

$ cat ~/.config/earthengine/credentials
{}
gena commented 6 years ago

At least {} is fixed in the latest github version, but it still hangs using the above scenario - will investigate further

gena commented 6 years ago

fixed