Connecting Google REST API through my REST API is not working Connecting Google REST API through my REST API is not working codeigniter codeigniter

Connecting Google REST API through my REST API is not working


Your REST client doesn't handle the oauth authentication, does it? I assume you shall authenticate your REST client somehow to let it use the access token delivered by Google.

To do so manually, you might save once the access token you've received from Google to a datastore when accessing your API manually (using your browser for instance and by inspecting your browser session). Having this access token available, you could then restore a valid session for your REST client.

Authenticating your REST client towards Google, can be done using cURL or reusing some existing library such as https://github.com/philsturgeon/codeigniter-oauth2.git. To authenticate your REST client towards your own API, you could use HTTP basic/digest authentication (as suggested by CodeIgniter-REST client) after having added an authentication extra-layer to your api (if it is missing).

P.S. When authenticating your user, in case of failure, the 401 response status code might be more legit (see also http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2)


problem is cross domain request error. You can connect

localhost/hac_dc/api/auth/user/ahmed.samy.cs@gmail.com

because your server performs as web proxy. but you can't do it directly via REST with simple getJSON technique. you can use JSONP in jquery ajax,it's 100% working for cross domain. JSONP is not JSON, it returns js function call to callback method with JSON parameter.you can achieve in following ajax call. But there is no 'success' callback in JSONP and for this purpose you must supply callback parameter in ajax call and define that callback function.

$.ajax({       crossDomain: true,       type:"GET",       contentType: "text; charset=utf-8",       url: YOUR_URL + "&callback=mycallback",        jsonp:'jsonp',       dataType: "jsonp"       });function mycallback(result){    //your callback operation}