iPhone – How to formulate POST to create users using basic HTTP authentication and design Rails GEM

For this certification business, I am a novice. So I have been looking for, but could not find any direct solution:

I use Devise gem got Rails backend for user authentication and iPhone frontend. I need to know how to create users from iPhone.

I already have the resources on how to create asynchronous posts, but I need to understand HTTP identity better The general concept of authentication-for example, if I use Curl to create a post to create a user authentication using basic HTTP, what is the curl command I will send to’www.example.com/createuser’?

For this example, the user model attributes of my Rails application are email and password.

Thank you very much for any suggestions/resource links. I appreciate it very much!

Best,
Jared

Basically it’s just Post the correct data to the user created path (run rake routing to see all the routes created for you after the device is properly installed). For example, I use one of my apps (using the command line curl) to do this:

< /p>

curl -H "Content-Type:application/json" -H "Accept:application/json" -d "{\"user\":{\"email\" :\"[email protected]\", \"password\":\"super_secret_pass\", \"password_confirmation\":\"super_secret_pass\"}}" http://jared-dev/users

.. I am back:

{"status":"signed_in"}

.. and just to verify that it works:

p>

irb(main):001:0> User.find_by_email('[email protected]')
=> #

In this example, I posted JSON data because I think it is easier to read, but you can also curl to make standard formdata. According to this post, I have to modify my application controller to support JSON for auth.

These The command line options correspond to the CURLOPT_HTTPHEADER, CURLOPT_POST and CURLOPT_POSTFIELDS set by curl_easy_setopt when using the libcurl easy interface.

I hope to help.

For this certification Business, I am a newbie. So I have been searching but couldn’t find any direct solution:

I used Devise gem to get Rails backend for user authentication and iPhone frontend. I need to know how to create a user from an iPhone.

I have mastered the resources on how to create asynchronous posts, but I need to better understand the general concept of HTTP authentication-for example, if I use Curl to create a post To create a user authentication using basic HTTP, what is the curl command I will send to’www.example.com/createuser’?

For this example, the user model attributes of my Rails application are email and password.

Thank you very much for any suggestions/resource links. I appreciate it very much!

Best,
Jared

Basically this is just posting the correct data to the user creation path (run rake Routes to see all the routes created for you after the device is properly installed). For example, I use one of my apps (using the command line curl) to do this:

curl -H "Content-Type:application/json" -H "Accept:application/json" -d "{\"user\":{\"email\":\"[email protected]\", \ "password\":\"super_secret_pass\", \"password_confirmation\":\"super_secret_pass\"}}" http://jared-dev/users

.. I am back:

{"status":"signed_in"}

.. and just to verify that it works:

 irb(main):001:0> User.find_by_email('[email protected]')
=> #

In this example, I posted the JSON data because I think it’s easier to read, but you You can also use curl to make standard formdata. According to this post, I have to modify my application controller to support JSON for auth.

These command line options correspond to those set by curl_easy_setopt when using the libcurl easy interface CURLOPT_HTTPHEADER, CURLOPT_POST and CURLOPT_POSTFIELDS.

I hope it helps.

Leave a Comment

Your email address will not be published.