evan108108 / RESTFullYii

RESTFull API for your Yii application

Home Page:http://evan108108.github.com/RESTFullYii/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GET Request from Postman (Chrome) work but not from iOS REST Client

kuldeepkod opened this issue · comments

@evan108108 Is it possible to check and let me know what might be going wrong?
I have integrated the version 1.15 of the RestfullYii extension in my Yii application. I'm on Apache2.2.27/PHP 5.3/MySQL on a LINUX AMI (AWS). According the the documentation, I have updated my Controller and config according to the instructions.
In my Controller, I had also included a restEvents() method to comprising these event methods req.auth.ajax.user, config.application.id, req.auth.username (return admin@restuser), req.auth.password (return 'admin@Access'). req.auth.user (always, return true;), BUT removed them later as they did not seem to have any effect.

When I make a GET call (Basic, without any header, username, password) from Postman (REST Client in Chrome browser), I get a response with correct data from MySQL table 👍

However, when I make a call from cURL / an iOS App (App name is: 'REST Client'), I get {"success": false, "message": You are not authorized to preform this action.","data":{errorcode":401}} 👎
From the iOS App, I also tried by setting name / value in addition to the URL i.e. X-REST-USERNAME to admin@restuser & X-REST-PASSWORD as admin@Access, still the same error message. [Also tried with underscored iso dashes]

Note: The documentation of v1.15 of RestfullYii hints at merging the filters and acessRules methods with Parent methods of the ERestController but does not provide the body. So here is what my Controller looks now.

onRest('req.auth.ajax.user', function() { return true; }); } public function validateAjaxUser($action) { //some logic return true; } public function _filters() { return array( 'accessControl', // perform access control for CRUD operations array( 'restfullyii.filters.ERestFilter + REST.GET, REST.PUT, REST.POST, REST.DELETE' ), ); } public function actions() { return array( 'REST.'=>'restfullyii.actions.ERestActionProvider', ); } public function _accessRules() { return array( array('allow', 'actions'=>array('REST.GET', 'REST.PUT', 'REST.POST', 'REST.DELETE'), 'users'=>array('_'), ), array('deny', // deny all users 'users'=>array('_'), ), ); } }

@kuldeepkod :> You are using a very old version which pre-dates the "onRest" "event" lib. You seem to be mixing and matching two very different versions in your code.

I would recommend that either you upgrade to the latest version (the master branch) or if you are using php5.3 switching to cccssw's amazing 5.3 port: https://github.com/cccssw/RESTFullYii

Thank you @evan108108 ... Your suggestion of switching to cccssw's amazing 5.3 port: https://github.com/cccssw/RESTFullYii worked for me.
I managed to get awesome RestfullYii extension to roll - thanks again!