Magento API REST customer not redirecting to Authentication Page

后端 未结 4 584
南方客
南方客 2021-01-16 05:30

I am trying to access products through Customer account. To achieve this I am using sample code from oauth_customer.php magento documentation page.
Everything i

4条回答
  •  生来不讨喜
    2021-01-16 06:03

    At last I found the solution myself. I decided to post here so it might be helpful for someone. Well by following the sample code from : https://docs.google.com/file/d/0BzCDl5a0zmSVdWdFMG9jMTB1TXM/edit?pli=1 I was able to get the redirect url. But the redirected path moved to 404 page as the redirect adds the redirect link with site URL. The code for redirecting to URL was $this->_redirectUrl($session->getBeforeAuthUrl(true));
    I changed this code to header( "refresh:1;url=".$session->getBeforeAuthUrl(true)); So it redirected to the Authorization page successfully. I assume that magento takes some miliseconds to create its cookies. So I added some refresh time to it. Here is the AccountController class code: {yourmagento}/app / code / community / Chalkfy / OAuthRedirect / controllers / AccountController.php

    _getSession();
            // if this redirect is a result of the OAuth process, force the redirect
            if(stristr($session->getBeforeAuthUrl(),"oauth/authorize?oauth_token=") == 0 )
            {
                echo "Redirecting Please Wait..";
                // Redirect to the URL after get
                header( "refresh:1;url=".$session->getBeforeAuthUrl(true));
    
                // $this->_redirect($session->getBeforeAuthUrl(true));
    
            }
            else {
                parent::_loginPostRedirect();
            }
    
    
        }
    
    
    }
    

提交回复
热议问题