Chrome 拡張機能でgapiクライアントを使用してGoogle ドライブにアクセスしています。最初のステップは、アプリを承認することです。私は許可を開始するために gapi.auth.authorize を使用しています。gapi によって起動されたポップアップからアプリを承認した後、ウィンドウが閉じず、下の図のように動かなくなります。ただし、ウィンドウを手動で閉じると、次回スタックしたポップアップが表示されないため、承認はバックグラウンドで成功しました。誰かが私が間違っていることを指摘できますか?
認証ポップアップで「アクセスを許可」をクリックした後、
次に、スタックしている空白のポップアップが表示されます
私が使用しているコード
function handleClientLoad(){
gapi.client.setApiKey('My API key');
window.setTimeout(checkAuthAuto, 1);
}
var checkAuthAuto = function () {
console.log('checkAuthAuto');
gapi.auth.authorize({
client_id: 'My client id',
scope: 'https://www.googleapis.com/auth/drive.file',
immediate: true
}, handleAuthResult);
}
function handleAuthResult(authResult) {
console.log('handleAuthResult');
var authButton = document.getElementById('authorizeButton');
var filePicker = document.getElementById('filePicker');
var addButton = document.getElementById('addButton');
authButton.style.display = 'none';
filePicker.style.display = 'none';
addButton.style.display = 'none';
if (authResult && !authResult.error) {
addButton.style.display = 'block';
addButton.onclick = uploadFile;
console.log('handleAuthResult:noerror');
} else {
// No access token could be retrieved, show the button to start the authorization flow.
authButton.style.display = 'block';
console.log('handleAuthResult:error');
console.log(authResult);
authButton.onclick = function() {
console.log('authButton.onclick');
gapi.client.setApiKey('My api key');
gapi.auth.authorize({
client_id: 'My client id',
scope: 'https://www.googleapis.com/auth/drive.file',
immediate: false
}, handleAuthResult);
return false;
};
}
}