In my node (v5.5.0) app, I'm making a request to the Google Groups Settings API via the google-oauth-jwt package but the response is coming back as XML (or ATOM?). The documentations seems to suggest you can your response as either ATOM or JSON, but it's not clear how. I'm also wondering why google-oath-jwt doesn't do the parsing.
My Code:
require('dotenv').load({ silent: true });
var request = require('google-oauth-jwt').requestWithJWT();
const email = process.env.GOOG_SERVICE_ACCOUNT;
const key = new Buffer(process.env.GOOG_SERVICE_ACCOUNT_KEY_BASE64, 'base64').toString();
const GoogleApiRequester = {
get: function(url, scopes, delegationEmail, callback) {
const jwt = { email, key, scopes, delegationEmail };
const options = {
method: 'get',
url,
jwt,
json: true
};
request(options, (err, res, body) => {
if (err) return callback(err);
if (body.error) return callback(body.error);
return callback(null, body);
});
}
}
The response:
<?xml version="1.0" encoding="UTF-8"?>\n<entry xmlns="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006" xmlns:gd="http://schemas.google.com/g/2005">
<id>tag:googleapis.com,2010:apps:groupssettings:GROUP:testing123@mydomain.org</id>
<title>Groups Resource Entry</title>
<content type="text">Administrators</content>
<author>
<name>Google</name>
</author>
<apps:email>testing123@mydomain.org</apps:email>
<apps:name>Administrators</apps:name>
<apps:description>All admin at 13W320</apps:description>
<apps:whoCanJoin>CAN_REQUEST_TO_JOIN</apps:whoCanJoin>
<apps:whoCanViewMembership>ALL_MANAGERS_CAN_VIEW</apps:whoCanViewMembership>
<apps:whoCanViewGroup>ALL_MEMBERS_CAN_VIEW</apps:whoCanViewGroup>
<apps:whoCanInvite>ALL_MANAGERS_CAN_INVITE</apps:whoCanInvite>
<apps:whoCanAdd>ALL_MANAGERS_CAN_ADD</apps:whoCanAdd>
<apps:allowExternalMembers>false</apps:allowExternalMembers>
<apps:whoCanPostMessage>ANYONE_CAN_POST</apps:whoCanPostMessage>
<apps:allowWebPosting>true</apps:allowWebPosting>
<apps:maxMessageBytes>26214400</apps:maxMessageBytes>
<apps:isArchived>false</apps:isArchived>
<apps:archiveOnly>false</apps:archiveOnly>
<apps:messageModerationLevel>MODERATE_NONE</apps:messageModerationLevel>
<apps:spamModerationLevel>MODERATE</apps:spamModerationLevel>
<apps:replyTo>REPLY_TO_IGNORE</apps:replyTo>
<apps:customReplyTo/>
<apps:sendMessageDenyNotification>false</apps:sendMessageDenyNotification>
<apps:defaultMessageDenyNotificationText/>
<apps:showInGroupDirectory>false</apps:showInGroupDirectory>
<apps:allowGoogleCommunication>false</apps:allowGoogleCommunication>
<apps:membersCanPostAsTheGroup>false</apps:membersCanPostAsTheGroup>
<apps:messageDisplayFont>DEFAULT_FONT</apps:messageDisplayFont>
<apps:includeInGlobalAddressList>true</apps:includeInGlobalAddressList>
<apps:whoCanLeaveGroup>ALL_MEMBERS_CAN_LEAVE</apps:whoCanLeaveGroup>
<apps:whoCanContactOwner>ANYONE_CAN_CONTACT</apps:whoCanContactOwner>
</entry>