Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Classroom API - Student's "emailAddress" and "photoUrl" are not coming in the response

I have a query regarding Student's Response of courses.

I am not getting two parameters in API call (emailAddress and photoUrl)

While calling the URL to the API "https://classroom.googleapis.com/v1/courses/{courseId}/students" via my code.

I am getting the following response:

{
  "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"
        }
      }
    }
  ]
}

But, when I execute it in Google Classroom's developer console by passing same courseId, I am getting response as follows:

{
 "students": [
  {
   "courseId": "303431573",
   "userId": "104377167089915657872",
   "profile": {
    "id": "104377167089915657872",
    "name": {
     "givenName": "student2",
     "familyName": "User",
     "fullName": "student2 User"
    },
    "emailAddress": "[email protected]",
    "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": "[email protected]",
    "photoUrl": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg"*
   }
  }
 ]
}
like image 871
Praveen Aella Avatar asked Oct 31 '22 16:10

Praveen Aella


1 Answers

Praveen - to access emailAddress and photoURL you'll need to request the following additional OAuth scopes:

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

Check out https://developers.google.com/classroom/guides/auth for more details.

like image 97
Zach Yeskel Avatar answered Nov 15 '22 05:11

Zach Yeskel