如何获得用户';来自Magento REST API令牌的id?

如何获得用户';来自Magento REST API令牌的id?,api,magento,rest,oauth,token,Api,Magento,Rest,Oauth,Token,接下来,很容易看到Magento在授予OAuth令牌后将其与用户id相关联。有没有一种方法可以在给定OAuth令牌的情况下以编程方式恢复用户id?如果有帮助,您可以这样做: // Should be a collection of one element (or zero if nothing found) $tokens = Mage::getModel('oauth/token')->getCollection()->addFilterById($tokenId); foreac

接下来,很容易看到Magento在授予OAuth令牌后将其与用户id相关联。有没有一种方法可以在给定OAuth令牌的情况下以编程方式恢复用户id?

如果有帮助,您可以这样做:

// 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();
}