Skip to content

Authentication API's

Akash Devaraju edited this page Jan 22, 2016 · 7 revisions

Basic Authentication

Register a User

  1. 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

  2. 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"]
     }
    
  3. 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

Clone this wiki locally