We've moved discussions to Discord

API Registration from Mobile App

Mike Kelly
The majority of my users will live their entire time through the mobile app and never see the web app.  As I understand it, the only way for a mobile to access the api out of the box is for a current user to manually create an api key and add it to the mobile app. Not really an option for me. 

If you were me, how would you go about cracking this nut?
Thanks!
Chris Oliver
Hey  Mike Kelly

You'd simply want to create a user registration endpoint in the API that doesn't require an API token. Let them submit nam, email, password, etc and create the record. Something like "POST /api/v1/users"

If it succeeds, return the user details and the API token in a JSON response. If it fails, return the errors in a response.
Chris Oliver
This would be a pretty solid feature to have in Jumpstart Pro, so I'll probably try and add that at some point in the near future.

I'm currently underwater finishing the Stripe SCA updates, which are I think all complete, just needing a few tests now and should release this week if all goes well.
Mike Kelly
Thanks for the help! That is way more straight forward than I was going.  I hate when I get too deep and over think this stuff.  That would be a great feature to be baked in.
Chris Oliver
I do that constantly too. Usually takes me several iterations to think something through and simplify it to what it needs to be. Jumpstart Pro went through that for about a year of iterations before launch. 👍

I'll see what I can do. It shouldn't be too hard to build a prototype.
Chris Oliver
Just pushed up a commit for this. You can POST to /api/v1/users with the same params (user[name], user[email], user[password], etc) that the registration form has.

It will return either errors or the user and an API token it automatically creates for them.
Mike Kelly
You kick ass man!  Thanks for that.  Not going to lie, I was struggle bussing through devise a bit, I mean learning a lot about the gem but struggle bussing none the less.  After going over your changes it is a bit or a moral boost to know I was on the right track.  The best part is, I wasn't going to let myself go to bed before I had a successful user post through the api.  I'll be getting to bed before midnight for the first time this week.

Thanks again!
Chris Oliver
Yeah! I had to learn that myself today too. I was like surely we can reuse this somehow. I had to read the source code of Devise to figure it out, but it was a great way to learn Devise a bit better. 🙌
Notifications
You’re not receiving notifications from this thread.