Creating (or say extending) an API where customer can login by Facebook/Google so I want get the same token which magento generates (same as if we login normally).

Reason is that if I will get that token then same I can use to access the other APIs (which magento has already developed)..

Is there anybody having idea ?? except Password I can give all the customer information..

  • Did you get a solution for problem? I am suffering from it. please check this link: [magento.stackexchange.com/questions/175480/… – Jsparo30 May 28 '17 at 11:16
  • Yeah.., I found the solution, do you need that? – Mohammad Mujassam May 29 '17 at 2:48
  • Yes, Please.... – Jsparo30 May 29 '17 at 8:16
  • so basically u need the token key after passing the customer data, correct ? rest logic of validation will be your ? – Mohammad Mujassam May 29 '17 at 9:24
  • Yes, I can save customer data from facebook or twitter, but I want to get token so i can call all api which request authorization. which validation part you mean? – Jsparo30 May 29 '17 at 9:56

Yes, there is a way to login bny customerid but I am not sure about customer token.

 $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
 $session = $objectManager->create('Magento\Customer\Model\Session');
        if ($session->loginById($customerId)) {

customer will login by above code and now get customer data from session

   $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
   $customerSession = $objectManager->create('Magento\Customer\Model\Session');

if ($customerSession->isLoggedIn()) {
   $customerSession->getCustomerId();  // get Customer Id

   echo $customerSessionget->getCustomer()->getName();  // get  Full Name
   echo $customerSessionget->getCustomer()->getEmail(); // get Email
|improve this answer|||||
  • How can I call all APIs which request token ? I can't understand your answer, Do you mean I can use the ID generated without of token or what ? – Jsparo30 May 28 '17 at 11:20
  • Token is being generated dynamically, So if you want to generate token you have to follow same process as Customer module does. – Ronak Chauhan Aug 30 '17 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.