CodeIgniter Forums
Philip Sturgeon REST Server / Rest Client working with API auth - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Philip Sturgeon REST Server / Rest Client working with API auth (/showthread.php?tid=39126)



Philip Sturgeon REST Server / Rest Client working with API auth - El Forum - 03-01-2011

[eluser]Flyingbeaver[/eluser]
Hi Wink

I've been trying to work with the API auth and I can generate keys, but whatever I do I always get : Response Not authorized.

Has someone tried it and could share the method please ?

So far I've done this... (#fail)
Code:
<?php
class Test extends CI_Controller {

    function  __construct()  {
        parent::__construct();
        
        $this->load->library('rest', array(  
            'server' => 'http://my-server:8888/api/'
        ));  
        $this->rest->api_key('7bbb53bb5f1a2c0c57ab6c909b675a29');  
    }

    function test()  
    {  
      $users = $this->rest->get('users');  
       echo $this->rest->debug();
    }  
}


Thx for help.


Philip Sturgeon REST Server / Rest Client working with API auth - El Forum - 03-01-2011

[eluser]Flyingbeaver[/eluser]
OK Wink

Here is how i do the job :

Code:
<?php
class Test extends CI_Controller {

    function  __construct()  {
        parent::__construct();
        
        $this->load->library('rest', array(  
            'server' => 'http://my-server:8888/api/'
        ));  
        
        $this->rest->api_key('7bbb53bb5f1a2c0c57ab6c909b675a29');
    }

    function test()  
    {  
      $key = $this->rest->put('users', '', 'json');  
      
      echo $this->rest->debug();
    }  
}

don't forget to enable api rest in rest config file and to remove auth from this file to.

If I'm doing it wrong plz let me know.

Thx phil for this amazing work Wink