0

我試圖以訪問學生的照片在谷歌課堂。我可以使用下面的代碼成功訪問照片網址。然而,當瀏覽器嘗試訪問該學生的照片,它得到一個403錯誤。我是否需要授權IMG標籤(和它一個連如何做到這一點?),還是有不同的步驟我失蹤?谷歌課堂個人資料照片權威性訪問

function getStudents(courseId) { 
    var pre = document.getElementById('content'); 
    gapi.client.classroom.courses.students.list({ 
     courseId: courseId, 
     pageSize: 0 
    }).then(function(response) { 
     var ss = response.result.students; 

     for (var i = 0; i < ss.length; i++) { 
      appendPre(ss[i]['profile']['name']['fullName']); 
      var imageContent = document.createElement('img'); 
      var photoUrl = ss[i].profile.photoUrl 
      if (photoUrl.substring(0,4) != "http") { 
       photoUrl = "https:" + photoUrl; // bug in API doesn't always include protocol 
      } 
      imageContent.setAttribute('src', photoUrl); 
      appendPre(photoUrl) 
      pre.appendChild(imageContent); 

     } 
    }) 
} 

回答

0

錯誤403課堂API與ClassroomApiDisabled消息表明您未被授權訪問數據:

ClassroomApiDisabled指示發出請求的用戶不具有 進入課堂API 。

可能採取的行動:將用戶引導到指示上enabling Classroom data access。此外 看到 NotGoogleAppsUser, 因爲用戶可能使用了錯誤的帳戶。

相關問題