How can I use the google API to retrieve custom roles for a user in a google group?
I noticed that within the "Roles" configuration UI in a Google Group, it is possible to add a custom role, by clicking the [CREATE] button. I can then assign that custom role to members of the google group.
However, when I use the API to retrieve the members of the group, it only shows one of the three built-in roles (OWNER, MEMBER and MANAGER), and not the custom roles. Is there an API call I can make to retrieve custom roles for the member of a google group?
Here is an excerpt of the code I'm using in nodeJs. Note that I'm using v1 of the directory API:
async function getGroupMembers(auth) {
try {
const admin = await google.admin({ version: 'directory_v1', auth });
admin.members.list({groupKey}, (err, payload) => {
if (err) {
console.log('The list users API returned an error: ', err);
resolve({ groups: , users: });
}
const data = payload.data;
const groups = ;
const users = ;
for (const member of data.members) {
console.log(member);
if (member.type === 'USER') users.push(member.email);
else if (member.type === 'GROUP') groups.push(member.email);
}
resolve({groups, users});
});
} catch(error) {
console.log("Error getting group members: ", error);
resolve({ groups: , users: });
}
}
Here is a sample of what I see when I console.log
the member variable:
{ kind: 'admin#directory#member',
etag: '"xxxxxxxxxxxxxxx"',
id: 'xxxxxxxxxxxxxx',
email: 'noreply@somedomain.com',
role: 'OWNER',
type: 'USER',
status: 'ACTIVE' }
But I hope to be able to see something like this:
{ kind: 'admin#directory#member',
etag: '"xxxxxxxxxxxxxxx"',
id: 'xxxxxxxxxxxxxx',
email: 'noreply@somedomain.com',
role: ['OWNER', 'MYCUSTOMROLE'],
type: 'USER',
status: 'ACTIVE' }
google-admin-sdk google-groups google-groups-api
add a comment |
I noticed that within the "Roles" configuration UI in a Google Group, it is possible to add a custom role, by clicking the [CREATE] button. I can then assign that custom role to members of the google group.
However, when I use the API to retrieve the members of the group, it only shows one of the three built-in roles (OWNER, MEMBER and MANAGER), and not the custom roles. Is there an API call I can make to retrieve custom roles for the member of a google group?
Here is an excerpt of the code I'm using in nodeJs. Note that I'm using v1 of the directory API:
async function getGroupMembers(auth) {
try {
const admin = await google.admin({ version: 'directory_v1', auth });
admin.members.list({groupKey}, (err, payload) => {
if (err) {
console.log('The list users API returned an error: ', err);
resolve({ groups: , users: });
}
const data = payload.data;
const groups = ;
const users = ;
for (const member of data.members) {
console.log(member);
if (member.type === 'USER') users.push(member.email);
else if (member.type === 'GROUP') groups.push(member.email);
}
resolve({groups, users});
});
} catch(error) {
console.log("Error getting group members: ", error);
resolve({ groups: , users: });
}
}
Here is a sample of what I see when I console.log
the member variable:
{ kind: 'admin#directory#member',
etag: '"xxxxxxxxxxxxxxx"',
id: 'xxxxxxxxxxxxxx',
email: 'noreply@somedomain.com',
role: 'OWNER',
type: 'USER',
status: 'ACTIVE' }
But I hope to be able to see something like this:
{ kind: 'admin#directory#member',
etag: '"xxxxxxxxxxxxxxx"',
id: 'xxxxxxxxxxxxxx',
email: 'noreply@somedomain.com',
role: ['OWNER', 'MYCUSTOMROLE'],
type: 'USER',
status: 'ACTIVE' }
google-admin-sdk google-groups google-groups-api
add a comment |
I noticed that within the "Roles" configuration UI in a Google Group, it is possible to add a custom role, by clicking the [CREATE] button. I can then assign that custom role to members of the google group.
However, when I use the API to retrieve the members of the group, it only shows one of the three built-in roles (OWNER, MEMBER and MANAGER), and not the custom roles. Is there an API call I can make to retrieve custom roles for the member of a google group?
Here is an excerpt of the code I'm using in nodeJs. Note that I'm using v1 of the directory API:
async function getGroupMembers(auth) {
try {
const admin = await google.admin({ version: 'directory_v1', auth });
admin.members.list({groupKey}, (err, payload) => {
if (err) {
console.log('The list users API returned an error: ', err);
resolve({ groups: , users: });
}
const data = payload.data;
const groups = ;
const users = ;
for (const member of data.members) {
console.log(member);
if (member.type === 'USER') users.push(member.email);
else if (member.type === 'GROUP') groups.push(member.email);
}
resolve({groups, users});
});
} catch(error) {
console.log("Error getting group members: ", error);
resolve({ groups: , users: });
}
}
Here is a sample of what I see when I console.log
the member variable:
{ kind: 'admin#directory#member',
etag: '"xxxxxxxxxxxxxxx"',
id: 'xxxxxxxxxxxxxx',
email: 'noreply@somedomain.com',
role: 'OWNER',
type: 'USER',
status: 'ACTIVE' }
But I hope to be able to see something like this:
{ kind: 'admin#directory#member',
etag: '"xxxxxxxxxxxxxxx"',
id: 'xxxxxxxxxxxxxx',
email: 'noreply@somedomain.com',
role: ['OWNER', 'MYCUSTOMROLE'],
type: 'USER',
status: 'ACTIVE' }
google-admin-sdk google-groups google-groups-api
I noticed that within the "Roles" configuration UI in a Google Group, it is possible to add a custom role, by clicking the [CREATE] button. I can then assign that custom role to members of the google group.
However, when I use the API to retrieve the members of the group, it only shows one of the three built-in roles (OWNER, MEMBER and MANAGER), and not the custom roles. Is there an API call I can make to retrieve custom roles for the member of a google group?
Here is an excerpt of the code I'm using in nodeJs. Note that I'm using v1 of the directory API:
async function getGroupMembers(auth) {
try {
const admin = await google.admin({ version: 'directory_v1', auth });
admin.members.list({groupKey}, (err, payload) => {
if (err) {
console.log('The list users API returned an error: ', err);
resolve({ groups: , users: });
}
const data = payload.data;
const groups = ;
const users = ;
for (const member of data.members) {
console.log(member);
if (member.type === 'USER') users.push(member.email);
else if (member.type === 'GROUP') groups.push(member.email);
}
resolve({groups, users});
});
} catch(error) {
console.log("Error getting group members: ", error);
resolve({ groups: , users: });
}
}
Here is a sample of what I see when I console.log
the member variable:
{ kind: 'admin#directory#member',
etag: '"xxxxxxxxxxxxxxx"',
id: 'xxxxxxxxxxxxxx',
email: 'noreply@somedomain.com',
role: 'OWNER',
type: 'USER',
status: 'ACTIVE' }
But I hope to be able to see something like this:
{ kind: 'admin#directory#member',
etag: '"xxxxxxxxxxxxxxx"',
id: 'xxxxxxxxxxxxxx',
email: 'noreply@somedomain.com',
role: ['OWNER', 'MYCUSTOMROLE'],
type: 'USER',
status: 'ACTIVE' }
google-admin-sdk google-groups google-groups-api
google-admin-sdk google-groups google-groups-api
asked Jan 2 at 23:08
Frank SconzoFrank Sconzo
11
11
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014352%2fhow-can-i-use-the-google-api-to-retrieve-custom-roles-for-a-user-in-a-google-gro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014352%2fhow-can-i-use-the-google-api-to-retrieve-custom-roles-for-a-user-in-a-google-gro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown