Authentication - muatik/logmon GitHub Wiki

Almost all API calls of Logmon requires authentication. You can authenticate with two API calls, namely sign-up and sign-in.

##Sign-up Using this API call, you can register an account in the system. If all goes well, registration will be completed successfully and you will receive a credential id to use for other API calls requiring authentication.

####Required Parameters

Field | Example | Description ---|:---|:---|: email | muatik@logmon.com | a valid email address password | veryhardtoguess | password equal to or longer than eight characters.

1. Example: Sign-up

####Request

POST /API/v1/auth/registration HTTP/1.1
Host: logmon.com

email=muatik@gmail.com&password=veryhardtoguess

####Response

HTTP/1.1 200 OK
Date: Mon, 09 Dec 2013 14:18:47 GMT
Set-cookie: CREDENTIAL_ID=g3b0hg4q48cusrkravuqe503g1

{
  "status" : {
    "code" : 20,
    "message" : "Registration completed successfully."
  },
  "data" : {
    "CREDENTIAL_ID" : "g3b0hg4q48cusrkravuqe503g1"
  }
}

##Sign-in Using this API call, you can sign in the system. If you provide a registered account, you will receive a credential id to use for other API calls requiring authentication.

####Required Parameters

Field | Example | Description ---|:---|:---|: email | muatik@logmon.com | a valid email address password | veryhardtoguess | password equal to or longer than eight characters.

1. Example: Sign-up

####Request

POST /API/v1/auth HTTP/1.1
Host: logmon.com

email=muatik@gmail.com&password=veryhardtoguess

####Response

HTTP/1.1 200 OK
Date: Mon, 09 Dec 2013 14:18:47 GMT
Set-cookie: CREDENTIAL_ID=g3b0hg4q48cusrkravuqe503g1

{
  "status" : {
    "code" : 20,
    "message" : "You are logged in successfully."
  },
  "data" : {
    "CREDENTIAL_ID" : "g3b0hg4q48cusrkravuqe503g1"
  }
}

##Using Credential After you signed-in to the system and get a credential id, you have the permission to use other API calls, for example getting the list of log registered by your account.

You need to send the credential id as a cookie in request header.

1. Example: Getting the list of log using a credential id

####Request

GET /API/v1/log HTTP/1.1
Host: logmon.com
Cookie: CREDENTIAL_ID=g3b0hg4q48cusrkravuqe503g1

####Response

HTTP/1.1 200 OK
Date: Mon, 09 Dec 2013 14:18:47 GMT

{
  "status" : {
    "code" : 20,
    "message" : "successful"
  },
  "data" : {
    "logs" : [
      {
        "id" : "988ab231241208832e124",
        "name" : "app log 1",
        "codeName" : "log1",
        "logConfig" : "..."
      }
    ]
  }
}

Changing email address

Using this API call, you can change the email address of the account associated your credential id.

Field | Example | Description ---|:---|:---|: password | notEasyPassword | current password newEmail | admin@internet.com | password equal to or longer than eight characters.

1. Example: Changing email address

####Request

POST /API/v1/auth/account/email HTTP/1.1
Host: logmon.com
Cookie: CREDENTIAL_ID=g3b0hg4q48cusrkravuqe503g1

newEmail=admin@internet.com&password=notEasyPassword

####Response

HTTP/1.1 200 OK
Date: Mon, 09 Dec 2013 14:18:47 GMT

{
  "status" : {
    "code" : 20,
    "message" : "The email has just been changed successfully."
  },
  "data" : {}
}

Changing password

Using this API call, you can change the password of the account associated your credential id.

Field | Example | Description ---|:---|:---|: password | veryeasy | current password newPassword | notEasyOne | new password

1. Example: Changing password

####Request

POST /API/v1/auth/account/password HTTP/1.1
Host: logmon.com
Cookie: CREDENTIAL_ID=g3b0hg4q48cusrkravuqe503g1

password=veryEasy&password=notEasyPassword

####Response

HTTP/1.1 200 OK
Date: Mon, 09 Dec 2013 14:18:47 GMT

{
  "status" : {
    "code" : 20,
    "message" : "The password has just been changed successfully."
  },
  "data" : {}
}