[英]Why won't my Google Picker Window Appear in The Browser
I am building out the google picker for a project I am working on. 我正在为我正在研究的项目构建Google选择器。 However, the script below is what I have written for utilizing the Google Picker API, to open the picker in the page to allow users to drop items into the drive.
但是,下面的脚本是我为利用Google Picker API编写的,用于在页面中打开选择器,以允许用户将项目放入驱动器。 I am trying to understand what is missing in the code functions that prevent the window from appearing.
我试图了解阻止窗口出现的代码功能中缺少的内容。
Should I include this into a button to activate it? 我应该将其包含在按钮中以将其激活吗?
<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>
You need to pass in the oauthToken variable to the setOAuthToken function call in your createPicker() function. 您需要将oauthToken变量传递给createPicker()函数中的setOAuthToken函数调用。 Everything else looks fine (presuming that you are using the right credentials).
其他一切看起来都很好(假设您使用的是正确的凭据)。 So your createPicker() function should look like this:
因此,您的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 );
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.