我正在为我正在从事的项目构建谷歌选择器。但是,下面的脚本是我为使用 Google Picker API 编写的,用于在页面中打开选择器以允许用户将项目放入驱动器中。我试图了解阻止窗口出现的代码函数中缺少什么。
我应该将其包含在一个按钮中以激活它吗?
<script>
function onApiload() {
gapi.load('auth', {'callback': onAuthApiLoad});
gapi.load('picker');
}
function onAuthApiLoad(){
window.gapi.auth.authorize({
'client_id': '596875534635.apps.googleusercontent.com',
'scope': ['https://www.googleapis.com/auth/drive']
}, handleAuthResult);
}
var oauthToken;
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
oauthToken = authReults.access_token;
createPicker();
}
}
function createPicker() {
var picker = new google.picker.PickerBuilder()
.addView(new google.picker.DocsUploadView())
.addView(new google.picker.DocsView())
.setAuthToken
.setDeveloperKey('AIzaSyBTsUe7i_eezFJ3ndIT8axJCR6IpksyLs8')
.build();
picker.setVisible(true);
}
</script>
<script src="https://apis.google.com/js/api.js?onload-onApiLoad">
</script>