How do you get a user's id from a Magento REST API token?

青春壹個敷衍的年華 提交于 2019-12-07 06:44:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!