问题
Following these instructions, it's easy to see that Magento is associating the OAuth tokens with a user id after they're granted. Is there a way to programmatically recover the user id, given the OAuth token?
回答1:
If helps, you can do it like this:
// Should be a collection of one element (or zero if nothing found)
$tokens = Mage::getModel('oauth/token')->getCollection()->addFilterById($tokenId);
foreach ($tokens as $token) {
echo $token->getCustomerId();
}
来源:https://stackoverflow.com/questions/18618079/how-do-you-get-a-users-id-from-a-magento-rest-api-token