Google drive api Google API列表权限下一个GetOken问题

Google drive api Google API列表权限下一个GetOken问题,google-drive-api,Google Drive Api,我无法将下一个getoken传递到dowhile循环的下一个迭代。这特别是drive.permissions.list api的问题。错误为“指定的页面令牌已过期,无法再使用”。当我在“while”行断点时,我可以看到nextpGetOken被更新为nextpGetOken。但是,它仍然会在下一个循环中抛出错误。我想这可能是异步函数本身以及代码如何/何时执行的问题,但是如果删除async/await,我会得到相同的结果。我对drive.drives.list有一个几乎相同的函数,它工作得非常好。

我无法将下一个getoken传递到dowhile循环的下一个迭代。这特别是drive.permissions.list api的问题。错误为“指定的页面令牌已过期,无法再使用”。当我在“while”行断点时,我可以看到nextpGetOken被更新为nextpGetOken。但是,它仍然会在下一个循环中抛出错误。我想这可能是异步函数本身以及代码如何/何时执行的问题,但是如果删除async/await,我会得到相同的结果。我对drive.drives.list有一个几乎相同的函数,它工作得非常好。任何帮助都将不胜感激。Thx

列出权限功能。在迭代期间不会将下一个GetOken传递到下一个Dow

async function listPermissions(auth, gdrive) {
const drive = google.drive({ version: "v3", auth });

let nextPageToken = null;
do {
   await drive.permissions.list({
        fileId: gdrive,
        pageSize: 100,
        pageToken: nextPageToken,
        supportsAllDrives: true,
        fields: "nextPageToken, permissions(id, type, role)",
        useDomainAdminAccess: true
    })
        .then((response) => {
            const permissions = JSON.stringify(response.data.permissions);
            console.log(`Permissions Detail: ${permissions}`)
            nextPageToken = response.data.nextPageToken;
            console.log(`NextPageToken: ${nextPageToken}`)
              //do work here
        })
        .catch(err => { console.log(`The API returned an error: ${err}`) })
} while (nextPageToken !== null);

} 
列表驱动器功能工作正常

async function listDrives(auth) {
const drive = google.drive({ version: "v3", auth });

let nextPageToken = null;
do {
    await drive.drives.list({
        pageSize: 100,
        pageToken: nextPageToken,
        fields: "nextPageToken, drives(id, name)",
        useDomainAdminAccess: true
    })
        .then((response) => {
            const drives = response.data.drives;
            nextPageToken = response.data.nextPageToken;
            //do work here
        })
        .catch(err => { console.log(`The API returned an error: ${err}`) })
} while (nextPageToken !== null);
}

尝试仅检索id,我对此表示怀疑,但可能是因为您检索的数据太多。嘿@Jescanellas,谢谢您的建议,但如果仅检索id,我会遇到相同的错误。如果您能提供帮助,我们将不胜感激。我目前正在标记具有>99权限的驱动器,以便稍后手动查看,但我希望让nextPageToken为此工作。Thx提前。