Skip to content

Instantly share code, notes, and snippets.

@mohamed-samir907
Last active July 22, 2019 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohamed-samir907/a3f4c5812b05098d8be61db27801131a to your computer and use it in GitHub Desktop.
Save mohamed-samir907/a3f4c5812b05098d8be61db27801131a to your computer and use it in GitHub Desktop.

User Authentication

The Base Host URL is http://BASE_URL/api add thes url before the follwinf urls in the API.

  1. User Login

Method:   POST
Url:   /oauth/login
Param:   email, password
Success:

{
    "message": "success",
    "data": {
        "token": "the user token"
    }
}

Erorr:
validation Errors or unauthorised

{
    "message": "error",
    "data": "unauthorised"
}

  1. User Registeration

Method:   POST
Url:   /oauth/register
Param:   name, email, password, confirm_password
Success:

{
    "message": "success",
    "data": {
        "token": "the user token",
        "user": "the user data"
    }
}

Erorr:
validation Errors or unexpected error

{
    "message": "error",
    "data": "unexpected error"
}

  1. Logout the User

This route can't access it without be authenticated.

Method:   POST
Url:   /oauth/register
Param:   name, email, password, confirm_password
Success:

{
    "message": "success",
    "data": "Logged out successfully"
}

Erorr:

{
    "message": "Unauthenticated",
}

  1. Get the user info

This route can't access it without be authenticated.

Method:   GET
Url:   /oauth/user
Param:   Send the access token with the header as Autherization
ex: Authorization Brearer token
Success:

{
    "message": "success",
    "data": {
        "id": 1,
        "name": "My Name",
        "email": "myemail@host.com",
        "email_verified_at": "2019-07-20 11:44:15",
        "created_at": "2019-07-20 17:03:37",
        "updated_at": "2019-07-20 23:44:15"
    }
}

Erorr:

{
    "message": "Unauthenticated",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment