我像这样加载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
。我缺少什么想法?
答案 0 :(得分:1)
好的,我弄明白了 - 加载库后我失去了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);