Authentication API v3

From Memsource
Jump to: navigation, search

Login

Most APIs require an authenticated user who is identified by a token. To obtain a token, call the following API and use the returned value in all subsequent calls. Each token is valid for 24 hours.

When 2-factor authentication is enabled and code parameter is missing or invalid, server returns error AuthAccountTwoFactorProtected.

action: api/v3/auth/login
    userName                    string                             
    password                    string
    code                        string                   O                  // if 2-factor authentication is enabled

response: JSON
    {
      "user": {
        "id":30,
        "firstName": "Admin",
        "lastName": "Istrator",
        "userName": "admin",
        "role":"Admin",                                 // ADMIN, LINGUIST, PROJECT_MANAGER
      }
      "token":"30-a3bf70333f8f1316cb7841cd774c9ce8",
      "expires":"2014-12-12T16:55:02Z"
    }

Login Another User

Creates a token for a user within the organization. Only ADMINs may use this API call.

The token can be used to login the user into the web user interface using the following URL. After the token is used in authByToken, it is deleted and cannot be used any longer.

https://cloud.memsource.com/web/login/authByToken?token=<token>&url=<url>
action: api/v3/auth/loginOther
    token                      string
    userName                   string

response: JSON
    {
      "user": {
        "id":35,
        "firstName": "Linguist",
        "lastName": "Lingo",
        "userName": "linguist",
        "role":"Linguist",                                 // ADMIN, LINGUIST, PROJECT_MANAGER
      }
      "token":"35-a3bf70333f8f1316cb7841cd774c9ce8",
      "expires":"2014-12-12T16:55:02+0000"
    }

Logout

action: api/v3/auth/logout
    token                      string

response: empty

Who Am I

This API call can be used to test if the previous auth/login call went ok. Although this API does not provide any essential functionality, it may still be useful during the development.

action: api/v3/auth/whoAmI
    token                      string

response: JSON
    {
      "user": {
        "id":30,
        "firstName": "Admin",
        "lastName": "Istrator",
        "userName": "admin",
        "role":"Admin",                                 // ADMIN, LINGUIST, PROJECT_MANAGER
      }
    }