모든 내 코드가 작동한다 제안하고, 중포 기지 기능의 로그는 콘솔 내가 떨어져 내 코드를 기반으로 한 Function execution took 6 ms, finished with status: 'ok'
가 반환을 보여줍니다 이 샘플 : 나는 작업 구글 - 시트의 예를 얻었다 후에 어떤에서 내가 로그 Function execution took 296 ms, finished with status: 'ok'
는 Node.js를과의 OAuth 토큰 Google 드라이브에 파일을 만들 수 없습니다
얻을 https://github.com/firebase/functions-samples/tree/master/google-sheet-sync는 , 나는 복사/붙여 넣은 몇 라인을 변경하지만, 아무리 내가 뭘 나는 것 같다 수 없습니다 basicaly Google 드라이브를 사용해보세요.
다음은 내가 작성한 코드입니다 (Google 시트의 예를 보면 기본적으로 어떻게 같은지 확인할 수 있습니다).
exports.makenewfolder = functions.database.ref(`${CONFIG_DATA_PATH}/{ITEM}`).onWrite(
event => {
// Since we're not dealing with the data from the DB, don't need the spreadsheets info
// Just need to return the promise with auth included
/*var fileMetadata = {
'name': 'test folder',
'mimeType': 'application/vnd.google-apps.folder'
};*/
var fileMetadata = {
name: 'Test',
mimeType: 'text/plain'
}
return drivePromise(this.fileMetadata);
}
)
function drivePromise(requestWithoutAuth) {
return new Promise((resolve, reject) => {
getAuthorizedClient().then(client => {
const service = google.drive({ version: 'v3', auth: client });
const request = requestWithoutAuth;
request.auth = client;
service.files.create({
resource: {
name: 'Test',
mimeType: 'text/plain'
},
media: {
mimeType: 'text/plain',
body: 'Hello World'
}
}, (err, file) => {
if (err) {
// handle error
console.error(err);
} else {
console.log('Folder id: ', file.id);
}
}
);
}).catch(() => reject());
})
}
왜 작동하지 않습니까? 범위가 https://www.googleapis.com/auth/drive
대신 /auth/spreadsheets
이 아니므로 작동해야합니다. 따라서 스프레드 시트가 Google 드라이브에 있다는 사실을 제외하고는 스프레드 시트를 더 이상 수정할 수 없어야합니다. 샘플의 나머지 코드를 포함하는 코드를 실행하면 스프레드 시트가 여전히 업데이트됩니다. 로그에 이러한 함수가 호출 중이지만 Google 드라이브에는 아무 것도 표시되지 않습니다. 이 문제를 어떻게 해결할 수 있습니까?