5

I have installed the com_api component and plugin from the official site for REST calls. I should authenticate user login with a web service at another domain using REST POST. How should I do it? I have the login form and how should I make POST request after submitting the form. There is no proper documentation and no tutorials even. Please help.

  • 2
    Welcome tot JSE Rex. TechJoomla.com has a Documentation page, Forum and Support Ticket system. Have you tried using them first? – Lodder Mar 24 '16 at 9:40
7

In the context of a REST Api, each call is stateless. So, there is no "user login".

In a Joomla site, when a user is authenticated, the browser receives a cookie to authorize the navigation and access to restricted areas.

Thus, in a REST Api, you have to implement an authorization protocol, like OAuth, to generate access tokens.

  • In TechJoomla's com_api, you call the authentication request with user and password (there's also an option for a global key), check ApiAuthenticationLogin and ApiAuthentication.

    $app = JFactory::getApplication();
    $key = $app->input->get('key','','STRING');
    
    if(empty($key))
    {
        $key = $app->input->post->get('key','','STRING');
    }
    if(empty($key))
    {
        $this->set('auth_method',$params->get('auth_method','username'));
        $this->set('auth_method',$params->get('auth_method','password'));
        $this->set('auth_method', $params->get('auth_method', 'login'));
    }
    else
    {
        $this->set('auth_method', $params->get('auth_method', 'key'));
    }
    
  • In the upcoming Joomla 3.6, a new Joomla official REST API will be included and it's currently being developed, more info here Preparing for webservices API in 3.6.

Github repo: Joomla Webservices

In this case, authentication is temporarily based on Redcore_Oauth2.

Webservices in redCORE provide a RESTfull (Representational state transfer) interface for your site using HAL as a easy way to hyperlink between resources. Generating mapping XML file which will expose your webservice is very easy and you can read about them in following chapters.

We highly recommend using OAuth2 Server together with webservice API since it already brings token manipulation and ease of access to the data. redCORE already provide OAuth2 Server functionality and you can read more information here.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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