Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/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
Javascript 为什么赢了';我的Google Picker窗口不会出现在浏览器中_Javascript_Google Chrome_Google Drive Api_Google Picker - Fatal编程技术网

Javascript 为什么赢了';我的Google Picker窗口不会出现在浏览器中

Javascript 为什么赢了';我的Google Picker窗口不会出现在浏览器中,javascript,google-chrome,google-drive-api,google-picker,Javascript,Google Chrome,Google Drive Api,Google Picker,我正在为我正在从事的一个项目构建谷歌选择器。但是,下面的脚本是我为利用Google Picker API编写的,它在页面中打开Picker,允许用户将项目放入驱动器。我试图理解阻止窗口出现的代码函数中缺少了什么 我是否应该将其包含在按钮中以激活它 <script> function onApiload() { gapi.load('auth', {'callback': onAuthApiLoad}); gapi

我正在为我正在从事的一个项目构建谷歌选择器。但是,下面的脚本是我为利用Google Picker API编写的,它在页面中打开Picker,允许用户将项目放入驱动器。我试图理解阻止窗口出现的代码函数中缺少了什么

我是否应该将其包含在按钮中以激活它

    <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>

函数onapioad(){
load('auth',{'callback':onAuthApiLoad});
gapi.load(“选择器”);
}
函数onAuthApiLoad(){
window.gapi.auth.authorize({
“客户id”:“596875534635.apps.googleusercontent.com”,
'范围':['https://www.googleapis.com/auth/drive']
},handleAuthResult);
}
var oauthToken;
函数handleAuthResult(authResult){
if(authResult&!authResult.error){
oauthToken=authruelts.access\u令牌;
createPicker();
}
}
函数createPicker(){
var picker=new google.picker.PickerBuilder()
.addView(新的google.picker.DocsUploadView())
.addView(新的google.picker.DocsView())
.setAuthToken
.setDeveloperKey('AIzaSyBTsUe7i_eezFJ3ndIT8axJCR6IpksyLs8')
.build();
picker.setVisible(true);
}

您需要将oauthToken变量传递给createPicker()函数中的setOAuthToken函数调用。其他一切看起来都很好(假设您使用了正确的凭据)。因此,您的createPicker()函数应该如下所示:

function createPicker() {
    var picker = new google.picker.PickerBuilder()
        .addView( new google.picker.DocsUploadView() )
        .addView( new google.picker.DocsView() )
        .setOAuthToken( oauthToken )
        .setDeveloperKey( 'AIzaSyBTsUe7i_eezFJ3ndIT8axJCR6IpksyLs8' )
        .build();

    // Render the picker model
    picker.setVisible( true );
}

这真的很旧,但只是看到您有onload onApiLoad而不是onload=onApiLoad