This documentation supports the 18.05 version of Remedy Action Request System.

To view the latest version, select the version from the Product version menu.

Login information

All REST API calls must be authenticated. Instead of passing the full credentials on every REST API call, REST uses a token. The token is valid for a configurable amount of time and acts like a temporary password. 

Note

For more information on Token based authentication, watch the video on YouTube at  Example authentication.

This video is recorded using the earlier version of BMC Remedy AR System and is valid for BMC Remedy AR System 9.1 and later versions.

This section provides the following topics:

Issuing and sending the token

  1. The client creates a POST call and passes the user name, password, and authString in the Request headers using the /x-www-form-urlencoded content type.

    POST /api/jwt/login HTTP/1.1
    host: www.example.com
    
    username=SomeUser&password=mysecret&authString=authenticationstring
  2. The AR System server performs the normal authentication mechanisms to validate the credentials. If the credentials are valid, the AR Server generates a JSON Web Token (JWT).
    You can attempt a REST API call if you have a token. A single JWT token is valid for an hour. You can use a single token across multiple AR servers that are in the same server group.

    // comments not actually included, added for clarity
    {
        // the username
        "sub" : "SomeUser",
        // the Server-Connect-Name of the AR Server who issued the token
        "iss" : "www.example.com",
        // the UNIX time when the token was issued
        "iat" : 1408774310,
        // 2 minutes before "iat", to account for clock skew between servers
        "nbf" : 1408777790,
        // the UNIX time when the token expires, the duration being a configurable value (probably between 1 minute and 12 hours)
        "exp" : 1408777910,
        // a custom claim, the cache ID
        "_cacheId" : 13
    }

    Note

    If the user provides a blank password, the AR System server does not attempt to cross-reference the password.

  3. The JWT is signed and base64 encoded string, and is sent back as a response body to the HTTP request.

    HTTP/1.1 200 OK
    
    eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
  4. The client receives the token and uses it in all subsequent REST API calls through the Authorization header using the AR-JWT schema.

    GET /api/arsys/v1/entry/SomeForm HTTP/1.1
    Authorization: AR-JWT eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk

To create the token

All REST requests must be authenticated. REST uses token based authentication.

DescriptionCreates a new token.
URL qualifier/api/jwt/login
MethodPOST
Headers
HeaderValue
authString<authentication string>
Content-typeapplication/x-www-form-urlencoded
Body
KeyValue
username<username>
password<password>
ReturnsAn encoded string in the response body referred as TOKEN.

    This example provides information to create a token.

    Request URL

    POST http://localhost:8008/api/jwt/login

    Request headers

    Content-Length: 32
    Content-Type: application/x-www-form-urlencoded
    
    username=Allen&password=password
    

    Response body

    HTTP/1.1 200 OK
    Date: Wed, 03 Dec 2014 23:39:41 GMT
    Content-Type: text/plain
    Server: Jetty(8.1.15.v20140411)
    
    eyJhbGciOiJIUzI1NiJ9.
    eyJleHAiOjE0MTc2NTM1ODgsInN1YiI6IkFsbGVuIiwibmJmIjoxNDE3NjQ5ODY4LCJpc3MiOi
    JXLUNTRUlFUk9FLTI5LmFkcHJvZC5ibWMuY29tIiwianRpIjoiSURHQUFCRFVDMllHSUFONkJGUTJBQUFFUEZBNVFXIiwiX2NhY2hlSWQiOjQ3LCJpYXQiOjE0MTc2NDk5ODh9.
    V4LGLcEdwD8V_I4rzoWYYSZmEMA82LBB_lEfz4Xnz9Y
    

    The following is a sample code snippet for creating the token.

    package com.example;
    
    import java.nio.charset.StandardCharsets;
    import java.util.ArrayList;
    import java.util.List;
    
    import org.apache.http.HttpEntity;
    import org.apache.http.NameValuePair;
    import org.apache.http.client.entity.UrlEncodedFormEntity;
    import org.apache.http.client.methods.CloseableHttpResponse;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.impl.client.CloseableHttpClient;
    import org.apache.http.impl.client.HttpClients;
    import org.apache.http.message.BasicNameValuePair;
    import org.apache.http.util.EntityUtils;
    
    public class Login {
    
        public static void main(String[] args) throws Exception {
            // start HTTP POST to get a token
            CloseableHttpClient httpClient = HttpClients.createDefault();
            HttpPost httpPost = new HttpPost("http://localhost:8008/api/jwt/login");
    
            // send the username and password
            List<NameValuePair> nvps = new ArrayList<>();
            nvps.add(new BasicNameValuePair("username", "Allen"));
            nvps.add(new BasicNameValuePair("password", "password"));
            httpPost.setEntity(new UrlEncodedFormEntity(nvps));
    
            // make the call and print the token
            try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
                HttpEntity entity = response.getEntity();
                String token = EntityUtils.toString(entity, StandardCharsets.UTF_8);
                System.out.println(token);
            }
        }
    
    }

    To release the token

    Description Releases the token.
    URL qualifier/api/jwt/logout
    MethodPOST
    Headers
    HeaderValue
    Authorizationtoken

      This example provides information to release a token.

      Request URL

      POST http://localhost:8008/api/jwt/logout

      Request header

      Authorization: AR-JWT eyJhbGciOiJIUzI1NiJ9.
      eyJleHAiOjE0MTc2NTM1ODgsInN1YiI6IkFsbGVuIiwibmJmIjoxNDE3NjQ5ODY4LCJpc3MiOi
      JXLUNTRUlFUk9FLTI5LmFkcHJvZC5ibWMuY29tIiwianRpI
      joiSURHQUFCRFVDMllHSUFONkJGUTJBQUFFUEZBNVFXIiwiX2NhY2hlSWQiOjQ3LCJpYXQiOjE0MTc2NDk5ODh9.
      V4LGLcEdwD8V_I4rzoWYYSZmEMA82LBB_lEfz4Xnz9Y

      Response body

      HTTP/1.1 204 No Content
      Date: Wed, 03 Dec 2014 23:46:03 GMT
      Server: Jetty(8.1.15.v20140411)
      

      The following is a sample code snippet for releasing the token.

      package com.example;
      
      import org.apache.http.StatusLine;
      import org.apache.http.client.methods.CloseableHttpResponse;
      import org.apache.http.client.methods.HttpPost;
      import org.apache.http.impl.client.CloseableHttpClient;
      import org.apache.http.impl.client.HttpClients;
      
      public class Logout {
      
          public static void main(String[] args) throws Exception {
              String token = args[0];
      
              // start HTTP POST to logout and invalidate the token
              CloseableHttpClient httpClient = HttpClients.createDefault();
              HttpPost httpPost = new HttpPost("http://localhost:8008/api/jwt/logout");
      
              // add the token to the header
              httpPost.addHeader("Authorization", "AR-JWT " + token);
      
              // make the call and print the status
              try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
                  StatusLine status = response.getStatusLine();
                  System.out.println(status);
              }
          }
      
      }

      Related topics

      Was this page helpful? Yes No Submitting... Thank you

      Comments