-
Notifications
You must be signed in to change notification settings - Fork 0
Authentication API's
Akash Devaraju edited this page Jan 22, 2016
·
7 revisions
-
POST - http://localhost:3000/auth
Request Header should specify ContentType: Application/json
Body of the POST request should contain:
{ "email" : "[email protected]", "password" : "password-here", "password_confirmation" : "password-here", "optional_parameter" : "value", "config_name":"default", "confirm_success_url":"http:localhost:3000" }
Optional parameters in the sign_up form can be configured using reference - https://github.com/plataformatec/devise#strong-parameters
-
POST - http://localhost:3000/auth/sign_in - If email is not confirmed
Request Header should specify ContentType: Application/json
Body of the POST request should contain:
{ "email" : "[email protected]", "password" : "password-here", }
Response:
{ "success": false, "errors": : ["A confirmation email was sent to your account at [email protected]. You must follow the instructions in the email before your account can be activated"] }
-
POST - http://localhost:3000/auth/sign_in - After email confirmed
Request Header should specify ContentType: Application/json
Body of the POST request should contain:
{ "email" : "[email protected]", "password" : "password-here", }
Response: The whole user object is returned.
{ "data": { "id": 1, "provider": "email", "uid": "[email protected]", "name": null, "nickname": null, "image": null, "email": "[email protected]", "address": null } }
Note: Below mentioned files are important for looking at the code base of the devise_token_auth gem
- registrations_controller.rb - Create, Update and Delete User accounts
- sessions_controller.rb - SignUp, SignIn and SignOut
- set_user_by_token.rb - Set up a user by using uid, client and access-token
- token_validations_controller.rb - Validates a Token