Rest API

Auth Rest API

Authentication requests are responsible for a user account. It provides creating an account, changing data about it, and access it.

In this article you can read about all these requests:

  1. auth/signup
  2. auth/login with password & username
  3. auth/login with auth_key
  4. auth/getuserbyid
  5. auth/updateuser
  6. auth/logout
  7. auth/userlist

auth/signup

Request for creating a new user account.

Request

Request Method Content Type Request URL
POST Form Data https://gudhub.com/GudHub/auth/signup

It contains user object with standard registration information. The object "user" needs certain data to be created:

Property Type Description
fullname string contains full user name
password string contains user password
username string contains user email

Example:

   user: {
      "fullname" : "Jon Jerry",
      "password" : "mypassword",
      "username" : "jon@gudhub.com"
   }

Response

As a result you will get an object with all user data.

{
   "user_id" : 149,
   "accesstoken" : "hkpbqelu_jt-rxatjfvulzjgfj-qizjhunonbdto",
   "username" : "jon@gudhub.com",
   "fullname" : "Jon Jerry",
   "auth_key" : "jgjgGJHGgHGJGHJBGHJGG/DKJSL934394",
   "expirydate" : 1497912166008,
   "app_init" : 3444
}

Status Code

Name Description
200 Ok user is registered
400 Bad Request incorrect request syntax
600 user with such name does not exist

auth/login with password & username

There are two types of login requests. The first one is with the help of password and username. It contains password and username.

Request

Request Method Content Type Request URL
POST Form Data https://gudhub.com/GudHub/auth/login

It contains password and username.

Property Type Description
password string user account password
login string user account login

Example:

   password : mypassword
   username : jon@gudhub.com

Response

In return will be an array of existing applications.

apps_list:[{
   "user_id" : 149,
   "accesstoken" : "bd.ayazr-m.glypihesgsxjyzba.eskjvtrbatrzw",
   "username" : "jon@gudhub.com",
   "fullname" : "Jon Jerry",
   "auth_key" : "JXNCKJZNCKZKJCjkjbskjacks394934",
   "expirydate" : 1497912390112,
   "app_init" : 3444
}]

Status Code

Name Description
200 Ok success
401 Unauthorized wrong login or password
711 incorrect login
712 incorect password

auth/login with auth_key

Request for login into an existing account.

Request

Request Method Content Type Request URL
POST Form Data https://gudhub.com/GudHub/auth/login

It contains the auth key.

Property Type Description
auth_key string personal authentication key

Example:

   auth_key:
   hIHIHIUioihsbdospklmzxnHsdlkiojojojisjdnjvkbiuoajdnwjnufosfjji0045456/==

Response

As well as the first login request, this one will returns an array of existing applications.

{ 
   "user_id" : 116,
   "accesstoken" : "bccfcpmkkytbchwrgbfkq._roozssrs_dpjokyjyv_",
   "username" : "webmaster@atlasiko.com",
   "fullname" : "Web Master",
   "auth_key" : "jgjJGJGhjvHGCHghJGIuGgchgCa909/jhiuahxiu==",
    "expirydate" : 1497974317507
}

Status Code

Name Description
000 Unauthorized wrong auth_key
200 Ok success

auth/getuserbyid

This get request allows to get the user by his/her ID. It is automatically called when the user clicks on Sharing button. In fact, it returns the users who have permission for the application in which the request was called.

Request

Request Method Content Type Request URL
GET Query String Parameters https://gudhub.com/GudHub_Test/auth/getuserbyid

The request consists of a token and the ID of the user whose object will be retrieved.

Property Type Description
token string used to get access
id number ID of the user whose data are to be retrieved

Example:

   token: thog-tayjf-.k-cbeapsebnqawkphhiny-ursyqsn
   id: 1578

Response

In response, you will get the desired user, if his/her profile exists.

{
   "avatar_128": "https://gudhub.com/avatars/1578_9032_128.jpg",
   "avatar_512": "https://gudhub.com/avatars/1578_9032_512.jpg",
   "expirydate": 0,
   "fullname": "John Dow",
   "user_id": 1578,
   "username": "john@dow.com"
}

Status Code

Name Description
200 Ok user is registered

auth/updateuser

Request for updating data of the existing account.

Request

Request Method Content Type Request URL
POST Form Data https://gudhub.com/GudHub/auth/updateuser

It contains token and user object.

Property Type Description
token string using for getting access
user object created user

Example:

   Token: prijmtwlezsxxyromyzbx_eptm.etnkhaewwp-_y

   user:{
      "user_id" : 149,
      "fullname" : "Jon Jerry",
      "username" : "jon@gudhub.com",
      "avatar": "...",
      "app_init" : 3444
   }

Response

In result will be updated user data.

{
   "user_id" : 149,
   "username" : "jon@gudhub.com",
   "fullname" : "Jon Jerry",
   "expirydate" : 0,
   "app_init" : 3445
}

Status Code

Name Description
200 Ok success

auth/logout

Request for signing out of the account.

Request

Request Method Content Type Request URL
POST Form Data https://gudhub.com/GudHub/auth/logout

It contains only token.

Property Type Description
token string using for getting access

Example:

   token:
   hkpbqelu_jt-rxatjfvulzjgfj-qizjhunonbdto

Response

In reply will be a success message.

Logout OK for token: 
hkpbqelu_jt-rxatjfvulzjgfj-qizjhunonbdto

Status Code

Name Description
200 logout is success

auth/userlist

This request allows to get the list of users which have keyword matches. The keyword can contain any number of signs. The user list will be retrieved if it has at least three signs.

Request

Request Method Content Type Request URL
GET Query String Parameters https://gudhub.com/GudHub_Test/auth/userlist

The current request sends token and keyword.

Property Type Description
token string allows to get the access
keyword string contains the string that will be used to find users for the list

Example:

   token: thog-tayjf-.k-cbeapsebnqawkphhiny-ursyqsn
   keyword: john

Response

In response, you will get an array of matched user objects.

[{
   "avatar_128": "https://gudhub.com/avatars/6832_128.jpg",
   "avatar_512": "https://gudhub.com/avatars/6832_512.jpg",
   "expirydate": 0,
   "fullname": "John Dow",
   "user_id": 1578,
   "username": "john@dow.com"
}]

Status Code

Name Description
200 Ok user is registered
400 Bad Request incorrect request syntax