Skip to content

Commit c526284

Browse files
jpolitzclaude
andcommitted
Migrate from deprecated Google+ API (plus/v1) to People API (people/v1)
Joe says: This seems fairly straightforward. It does slightly change the permissions dialog to say “Email and profile photo” – we don't want or ask for anyone's profile photo, but we have to use the `profile` scope for the new API. There's not really a way around this that I can see; there's no email-only API. Claude says: The Legacy People API is deprecated and cannot be enabled for new Cloud Console projects. This migrates all user profile lookups to the modern People API (people/v1), which is the supported replacement. Changes: - Load 'people' v1 instead of 'plus' v1 via gwrap - Use resourceName/personFields params instead of userId - Update response field access (emailAddresses, names) - Add 'profile' OAuth scope required by People API Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7657f90 commit c526284

5 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/google-auth.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ var OAuth2 = gapi.auth.OAuth2;
44

55
var DEFAULT_OAUTH_SCOPES = [
66
"email",
7+
"profile",
78
"https://www.googleapis.com/auth/drive.file",
89
"https://www.googleapis.com/auth/drive.install",
910
];
1011

1112
var FULL_OAUTH_SCOPES = [
1213
"email",
14+
"profile",
1315
"https://www.googleapis.com/auth/spreadsheets",
1416
"https://www.googleapis.com/auth/drive.file",
1517
"https://www.googleapis.com/auth/drive",

src/web/js/beforeBlocks.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ $(function() {
305305
};
306306

307307
function setUsername(target) {
308-
return gwrap.load({name: 'plus',
308+
return gwrap.load({name: 'people',
309309
version: 'v1',
310310
}).then((api) => {
311-
api.people.get({ userId: "me" }).then(function(user) {
312-
var name = user.displayName;
313-
if (user.emails && user.emails[0] && user.emails[0].value) {
314-
name = user.emails[0].value;
311+
api.people.get({ resourceName: "people/me", personFields: "names,emailAddresses" }).then(function(user) {
312+
var name = user.names && user.names[0] ? user.names[0].displayName : undefined;
313+
if (user.emailAddresses && user.emailAddresses[0] && user.emailAddresses[0].value) {
314+
name = user.emailAddresses[0].value;
315315
}
316316
target.text(name);
317317
});

src/web/js/beforePyret.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,13 @@ $(function() {
333333
};
334334

335335
function setUsername(target) {
336-
return gwrap.load({name: 'plus',
336+
return gwrap.load({name: 'people',
337337
version: 'v1',
338338
}).then((api) => {
339-
api.people.get({ userId: "me" }).then(function(user) {
340-
var name = user.displayName;
341-
if (user.emails && user.emails[0] && user.emails[0].value) {
342-
name = user.emails[0].value;
339+
api.people.get({ resourceName: "people/me", personFields: "names,emailAddresses" }).then(function(user) {
340+
var name = user.names && user.names[0] ? user.names[0].displayName : undefined;
341+
if (user.emailAddresses && user.emailAddresses[0] && user.emailAddresses[0].value) {
342+
name = user.emailAddresses[0].value;
343343
}
344344
target.text(name);
345345
});

src/web/js/dashboard/GoogleAPI.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ class GoogleAPI {
151151
}
152152

153153
getUsername = () => {
154-
return gwrap.load({name: 'plus',
154+
return gwrap.load({name: 'people',
155155
version: 'v1',
156156
}).then((api) => {
157157
console.log("Api: ", api);
158-
return api.people.get({ userId: "me" });
158+
return api.people.get({ resourceName: "people/me", personFields: "names,emailAddresses" });
159159
});
160160
}
161161
}

src/web/js/dashboard/StudentDashboard.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class StudentDashboard extends Component {
3131
this.setState({signedIn: SIGNED_IN});
3232
this.updateRecentFiles();
3333
this.api.getUsername().then((userInfo) => {
34-
this.setState({ userName: userInfo.emails[0].value });
34+
this.setState({ userName: userInfo.emailAddresses[0].value });
3535
});
3636
}
3737
else {
@@ -52,7 +52,7 @@ class StudentDashboard extends Component {
5252
this.api.signIn().then((resp) => {
5353
this.setState({signedIn: SIGNED_IN});
5454
this.api.getUsername().then((userInfo) => {
55-
this.setState({ userName: userInfo.emails[0].value });
55+
this.setState({ userName: userInfo.emailAddresses[0].value });
5656
});
5757
this.updateRecentFiles();
5858
})

0 commit comments

Comments
 (0)