cancel
Showing results for 
Search instead for 
Did you mean: 

getSingleton( 'admin/session' ) REST compliant alternative

getSingleton( 'admin/session' ) REST compliant alternative

In my Magento installation there is an extension that adds a "created_by" field to my products. 

In the code of this extension I see that it does this with Mage::getSingleton( 'admin/session' )->getUser().

 

However, I create some products using REST, and than the Mage::getSingleton( 'admin/session' )->getUser() does not work since there is no admin/session I assume. 

 

Can anybody help me out? Is there some way I could do it like this: Mage::getSingleton( 'REST/session' )->getUser()?

1 REPLY

Re: getSingleton( 'admin/session' ) REST compliant alternative

I found a stackoverflow post where they suggest using this code to get the user ID in a REST connection.

 

$tokens = Mage::getModel('oauth/token')->getCollection()->addFilterById($tokenId);
foreach ($tokens as $token) {    echo $token->getCustomerId();
}

 

But I don't know what I should define in the $tokenId variable. Should I send along the consumerkey? 

 

http://stackoverflow.com/questions/18618079/how-do-you-get-a-users-id-from-a-magento-rest-api-token