How to add app_metadata to custom JWT claims

I want the app_metadata we’ve configured for a user to show up in the JWT claims. I’m testing with sandbox.it.auth0.com and Authentication API Debugger but can’t seem to get the extra info added to the id_token.payload. Here’s the rule that’s running in the sandbox:

module.exports = function(client, scope, audience, context, cb) {
  var access_token = context.access_token || {};
  access_token.scope = scope;
  access_token'https://blah.com/foo'] = 'bar';
  cb(null, access_token);
};

Any help would be appreciated.

edit: I’m trying to create a rule, but keep getting “Forbidden” when I save the rule.

function (user, context, callback) {
  console.log(user.app_metadata);
  context.idToken'https://blah.com/application_id'] = user.app_metadata.application_id;
  callback(null, user, context);
}

Can you provide the full error that you receive when trying to save the rule?

That was the full error. “Forbidden”

I’m an admin. I had a coworker try it and they were successful. Immediately after that I was able to do it as well.