google-api-nodejs-client: Drive download returning token JSON object
Hello, I’m having a problem downloading from the Drive using this API (v3). The data returned from the API is of the form:
{
"access_token" : "HUGE_TOKEN_STRING",
"token_type" : "Bearer",
"expires_in" : 3600
}
My code is roughly as follows (parts ommited due to confidentiality reasons):
var buffer = new Buffer(0);
drive.files.get({
auth: auth,
alt: 'media',
fileId: id,
})
.on('error', function (err) {
logger.error("Error " + err);
callback(err, null);
})
.on('data', function (data) {
logger.info("Got data!");
buffer = Buffer.concat([buffer, data], buffer.length + data.length);
})
.on('end', function () {
logger.info("End event!");
callback(null, buffer);
});
auth is an object created using a derivation of this example: https://developers.google.com/drive/v3/web/quickstart/nodejs#step_3_set_up_the_sample
Am I doing something wrong, or has the API changed somehow?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 5
- Comments: 27 (8 by maintainers)
Commits related to this issue
- File encoding on download Added ability to specify file enconding when downloading files from Google Drive. This also fixes #501 by applying the following: ```javascript drive.files.get({ fil... — committed to SamuelePilleri/google-api-nodejs-client by SamuelePilleri 8 years ago
- File encoding on download Added ability to specify file enconding when downloading files from Google Drive. This also fixes #501 by applying the following: ```javascript drive.files.get({ fil... — committed to SamuelePilleri/google-api-nodejs-client by SamuelePilleri 8 years ago
- File encoding on download Added ability to specify file enconding when downloading files from Google Drive. This also fixes #501 by applying the following: ```javascript drive.files.get({ fil... — committed to SamuelePilleri/google-api-nodejs-client by SamuelePilleri 8 years ago
- Add support for overriding request options. Fixes #501 Fixes #618 Fixes #621 — committed to googleapis/google-api-nodejs-client by jmdobry 8 years ago
- Add support for overriding request options. Fixes #501 Fixes #618 Fixes #621 — committed to googleapis/google-api-nodejs-client by jmdobry 8 years ago
- Add support for overriding request options. (#623) Fixes #501 Fixes #618 Fixes #621 — committed to googleapis/google-api-nodejs-client by jmdobry 8 years ago
- Always refresh Drive API OAuth tokens The Node.js Google API client has a strange behavior where the streaming API will stream a refresh token rather than the exported file when the token needs to be... — committed to thechicagoreporter/doj_tracker by ghing 7 years ago
Hi, I have similar issue. Turned out my problem was the access token getting expired. So I added a manual refresh before the oauth2Client callback in the node.js quickstart google api example link
replaced
by
Don’t know if it’s the best way but hope it helps.
I may need to re-open this issue, but I’d like to see if 12.4.0 works for anybody as far as the
encoding
goes. You should now be able to do:Agreed, pipe should not leak credentials. Opened #625