Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

353
Visualizações
obtener mi lista de archivos de Google Drive con autenticación de máquina a máquina usando javascript (insuficientes permisos de archivo)

Estoy tratando de obtener una lista de archivos (imágenes) de Google Drive:

  1. creo un proyecto de google (consola de google)
  2. activo google drive api en mi proyecto
  3. creo la clave api y la identificación del cliente

estoy usando javascript para manejar mi solicitud:

 const API_KEY = '...'; const ID_CLIENT = '...'; const scopes = [ 'https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file', 'https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/drive.activity', 'https://www.googleapis.com/auth/drive.activity.readonly', 'https://www.googleapis.com/auth/drive.metadata', 'https://www.googleapis.com/auth/drive.metadata.readonly', 'https://www.googleapis.com/auth/drive.scripts', 'Google_Service_Drive::DRIVE' ]; const googleDriveConf = { 'apiKey': API_KEY, 'clientId': ID_CLIENT, 'scope': scopes[1], 'plugin_name': 'Client Web deca' }; function start() { // Initialize the JavaScript client library and auth. gapi.client.init(googleDriveConf) .then(function () { // Initialize and make the API request. const req = gapi.client.request({ 'path': `https://content.googleapis.com/drive/v3/files`, 'method': 'GET', 'params': { 'q': 'mimeType = "image/jpeg"', } }) console.log(req) return req; }, function (reason) { console.log('auth: ', reason) }) .then(function (response) { console.log(response.result); }, function (reason) { console.log('fetch files: ', reason) //error source }); } gapi.load('client', start);

respuesta de error:

 { "error": { "errors": [ { "domain": "global", "reason": "insufficientFilePermissions", "message": "The user does not have sufficient permissions for this file." } ], "code": 403, "message": "The user does not have sufficient permissions for this file." } }

traté de arreglarlo sin ningún éxito

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Es posible que desee consultar el inicio rápido de JavaScript

 async function listFiles() { let response; try { response = await gapi.client.drive.files.list({ 'pageSize': 10, 'fields': 'files(id, name)', 'q': 'mimeType = "image/jpeg"', }); } catch (err) { document.getElementById('content').innerText = err.message; return; } const files = response.result.files; if (!files || files.length == 0) { document.getElementById('content').innerText = 'No files found.'; return; } // Flatten to string to display const output = files.reduce( (str, file) => `${str}${file.name} (${file.id}\n`, 'Files:\n'); document.getElementById('content').innerText = output; }

El mensaje de error que está recibiendo no tiene ningún sentido para mí. Al mirar su código "The user does not have sufficient permissions for this file." es un error que obtendría si estuviera, por ejemplo, haciendo un file.get.

File.list no devolvería este error.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda