Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google drive api 如何使用javascript加载google drive api?_Google Drive Api_Google Api Js Client - Fatal编程技术网

Google drive api 如何使用javascript加载google drive api?

Google drive api 如何使用javascript加载google drive api?,google-drive-api,google-api-js-client,Google Drive Api,Google Api Js Client,我像这样加载gapi: gapi.load('client:auth2', () => { var auth2 = gapi.auth2.init({ client_id: `${MYKEY}.apps.googleusercontent.com`, scope: 'profile https://www.googleapis.com/auth/drive.appfolder' }); console.log(ga

我像这样加载gapi:

gapi.load('client:auth2', () => {
      var auth2 = gapi.auth2.init({
          client_id: `${MYKEY}.apps.googleusercontent.com`,
          scope: 'profile https://www.googleapis.com/auth/drive.appfolder'
      });
      console.log(gapi.client.drive)
}

希望gapi.client.drive在加载后可用,但解析为null。你知道我遗漏了什么吗?

好的,我找到了答案-加载库后我遗漏了gapi.client.init步骤:

gapi.client.init({
        'apiKey': 'API_KEY',
        'discoveryDocs': ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'],
        'clientId': 'CLIENT_ID.apps.googleusercontent.com',
        'scope': 'https://www.googleapis.com/auth/drive.appfolder',
      }).then(SOME_CALLBACK);