Context
I want to download files via the browser from Google Drive. I am able to access the files' data and details, via drive.get but I am not able to export the files. I didn't see a binaryString in the response.
Then I got in the touch with the API-Explore, where I'm not able to download anything too. Any ideas/hints?
Notice my...
SCOPES: 'https://www.googleapis.com/auth/drive'- I obtained a Developer
API Keyat the Credentials Page - I obtained a
OAuth 2.0 Client IDs
Reproduce for you
Public hello world doc helloWorld
Details
mimeType:'application/vnd.google-apps.document'
id:'1O2ORp9te3FzqTFZkPLGNGvAnzcKBhdGZ-lu8TgABPrY'
API Explorer String
Response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "The requested conversion is not supported.",
"locationType": "parameter",
"location": "convertTo"
}
],
"code": 400,
"message": "The requested conversion is not supported."
}
}
local code
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<script type="text/javascript">
var developerKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
var clientId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
var appId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
var scope = 'https://www.googleapis.com/auth/drive.drive'
const mimeType = 'application/vnd.google-apps.document'
const fileID = '1O2ORp9te3FzqTFZkPLGNGvAnzcKBhdGZ-lu8TgABPrY'
function load() {
gapi.load('client:auth2', () => {
console.log(gapi)
gapi.client
.init({
clientId,
scope,
apiKey: developerKey,
discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'],
})
.then(
() => {
gapi.auth2.getAuthInstance().signIn()
gapi.client.load('drive', 'v3', () => {
gapi.client.drive.files
.export({
fileID,
mimeType,
})
.then(res => console.log(res))
.catch(error => console.error(error))
})
},
error => console.error(error)
)
})
}
</script>
</head>
<body>
<div id="result"></div>
<script type="text/javascript" src="https://apis.google.com/js/api.js?onload=load"></script>
</body>
</html>