How do I make an object available as a token? I have created a custom token. Inside my token's code, I'm getting a node object. I want to give the users the option of displaying this node's properties. So, for example, assuming that my token's name is [mycustomtoken] I want them to be able to write:

[mycustomtoken:author] so that they get the node's author or

[mycustomtoken:title] to get the node's title.

Is there a way to do this in Drupal?
Yes, by making your token a dynamic token in HOOK_token_info() and using the provided name during HOOK_tokens() to dynamically create your replacements.

Example

function HOOK_token_info() {
  ...

  $tokens['mycustomtoken'] = array(
     ...
     'dynamic' =&gt; TRUE,
  );

  ...
}

function HOOK_tokens($type, $tokens, array $data = array(), array $options = array()) {
  ...

  if ($type == 'mycustomtoken' &amp;&amp; !empty($data['node'])) {
    $node = $data['node'];

    foreach ($tokens as $name =&gt; $original) {
      if (isset($node-&gt;{$name})) {
        $replacements[$original] = $node-&gt;{$name};
      }
    }
  }

  ...
}