Thursday, August 30, 2012

Re: Tutorial for REST API user create and authenticate?

Awesome thanks dude! I just had a chance to play with that Platform-API-Plugin

It's pretty cool, everything returns nicely and POSTs are authenticated, I just can't workout how to generate or request an access token. Perhaps I have to setup my own endpoint?

Have you had a chance to try it out?

Cheers
Nathan

On Monday, August 13, 2012 5:16:57 PM UTC+10, Simon Males wrote:
Yeah API/REST Auth is a little tricky.

At the moment I'm checking the extension of the request (.json) in
AppController::beforeFilter(), then switching the Auth type to Basic
and then attempting $this->Auth->login().

When it's basic, the user/pass comes in via
http://user:pass@example.com/ and authenticated on every request.

Other guys from the team generate a token, and in the beforeFilter()
see if that token matches up a user record. If so manually login the
user.

Lastly, when I get a bit of time I'm going to look at this:
https://github.com/nodesagency/Platform-API-plugin

Hope that helps dude.

On Mon, Aug 13, 2012 at 4:40 PM, 42startups <he...@42startups.com> wrote:
> Simon! Yep it's me :)
>
> I worked out I didn't include the RequestHandler component.
>
> Second issue was formatting the POST data. Was trying to post raw json to
> /users.json using a chrome plugin. Didn't work, but a simple form did so
> long as the input name is in the format data[User][username]
>
> Got to workout API authentication now. Any pointers?
>
>
> On Mon, Aug 13, 2012 at 3:46 PM, Simon Males <si...@sime.net.au> wrote:
>>
>> Yo Nathan ? :)
>>
>> See first if you can make sense out of the below first. Shows your how
>> to return Json/Xml views.
>>
>> http://book.cakephp.org/2.0/en/views/json-and-xml-views.html
>>
>> Handling a JSON POST request is the same as handling a HTTP POST.
>>
>> On Mon, Aug 13, 2012 at 3:11 PM, 42startups <he...@42startups.com> wrote:
>> > Hi
>> >
>> > I'm looking for an up-to-date tutorial on creating a REST API using Cake
>> > so
>> > that I can send a POST request to create a new User and also a GET
>> > request
>> > to fetch and authenticate a User's username and password.
>> >
>> > I've found a few online, but they seem to be from the 1.3 Cake version.
>> > And
>> > the Cookbook instructions don't seem to work for me.
>> >
>> > Cheers
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "CakePHP" group.
>> > To post to this group, send email to cake...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > cake-php+u...@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>> >
>> >
>>
>>
>>
>> --
>> Simon Males
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to cake...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> cake-php+u...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake...@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>



--
Simon Males

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: