2017-09-16 70 views
0

我正在使用Google API {授權}功能請求日曆權限。該功能永遠不會完成網絡調用並引發此錯誤:

TypeError: Cannot read property '$k' of undefined 
    at rl (cb=gapi.loaded_0:183) 
    at pP (cb=gapi.loaded_0:215) 
    at qY (cb=gapi.loaded_0:211) 
    at WE.<anonymous> (cb=gapi.loaded_0:195) 
    at new _.C (cb=gapi.loaded_0:104) 
    at WE.W2 (cb=gapi.loaded_0:195) 
    at WE._.k.sY (cb=gapi.loaded_0:195) 
    at base.js:126 
    at h.r2 (cb=gapi.loaded_0:107) 
    at xs (cb=gapi.loaded_0:110) 

該代碼似乎工作,直到幾天前,沒有什麼真正改變。這是創建錯誤的最小示例:

function scheduleCalendar() { 
    console.log("Schedule calendar"); 
    gapi.load('auth2', function() { 
    gapi.auth2.init({ 
     discoveryDocs: DISCOVERY_DOCS, 
     clientId: CLIENT_ID, 
     scope: 'email' 
    }).then(function (googleAuth) { 
     console.log(googleAuth); 
     googleAuth.signIn().then(function() { 
     const googleUser = googleAuth.currentUser.get(); 
     console.log(googleUser); 
     const options = new gapi.auth2.SigninOptionsBuilder(
      {'scope': 'https://www.googleapis.com/auth/calendar'} 
     ); 
     googleUser.grant(options).then(
      function(success){ 
      console.log(success); 
      }, 
      function(fail){ 
      console.log(fail); 
      } 
     ); 
     }); 
    }); 
    }); 
} 
+0

什麼是在線:base.js:126?我會先看看那裏,確保你傳遞正確的值或使用正確的方法。你看到任何你的控制檯日誌? –

+0

第126行是對'googleUser.grant'的調用。我使用官方文檔[鏈接](https://developers.google.com/identity/sign-in/web/incremental-auth) – Geek

+0

的代碼是否碰巧輸入了錯誤的內容? – noogui

回答

0

事實證明這是Google API庫中的一種迴歸。這個問題似乎是固定的。

相關問題