【问题标题】:Google Classroom API - Student's "emailAddress" and "photoUrl" are not coming in the responseGoogle Classroom API - 学生的“emailAddress”和“photoUrl”没有出现在响应中
【发布时间】:2015-10-30 07:21:36
【问题描述】:

我对学生对课程的反应有疑问。

我在 API 调用中没有得到两个参数(emailAddress 和 photoUrl)

通过我的代码调用 API“https://classroom.googleapis.com/v1/courses/{courseId}/students”的 URL 时。

我收到以下回复:

{
  "students": [
    {
      "courseId": "303431573",
      "userId": "104377167089915657872",
      "profile": {
        "id": "104377167089915657872",
        "name": {
          "givenName": "student2",
          "familyName": "User",
          "fullName": "student2 User"
        }
      }
    },
    {
      "courseId": "303431573",
      "userId": "104304056850029354748",
      "profile": {
        "id": "104304056850029354748",
        "name": {
          "givenName": "student1",
          "familyName": "User",
          "fullName": "student1 User"
        }
      }
    }
  ]
}

但是,当我通过传递相同的 courseId 在 Google Classroom 的开发者控制台中执行它时,我得到如下响应:

{
 "students": [
  {
   "courseId": "303431573",
   "userId": "104377167089915657872",
   "profile": {
    "id": "104377167089915657872",
    "name": {
     "givenName": "student2",
     "familyName": "User",
     "fullName": "student2 User"
    },
    "emailAddress": "student2_rvnqrmpxeraft-mcygui@classroom-dev.com",
    "photoUrl": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg"
   }
  },
  {
   "courseId": "303431573",
   "userId": "104304056850029354748",
   "profile": {
    "id": "104304056850029354748",
    "name": {
     "givenName": "student1",
     "familyName": "User",
     "fullName": "student1 User"
    },
    *"emailAddress": "student1_kb5ysml_yw4l2ecbu581@classroom-dev.com",
    "photoUrl": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg"*
   }
  }
 ]
}

【问题讨论】:

    标签: java oauth-2.0 google-api google-classroom


    【解决方案1】:

    Praveen - 要访问 emailAddress 和 photoURL,您需要请求以下额外的 OAuth 范围:

    • https://www.googleapis.com/auth/classroom.profile.photos
    • https://www.googleapis.com/auth/classroom.profile.emails

    查看https://developers.google.com/classroom/guides/auth了解更多详情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-24
      • 2017-05-11
      • 2021-02-21
      • 1970-01-01
      • 2020-08-31
      相关资源
      最近更新 更多