Skip to content

Examples

Here is an example of how to retrieve all tokens that are issued to a user.

Retrieve All Tokens

Request using the ‘curl’ command:

curl -X GET \
https://secure.cigital.com/api/public/v3/access-tokens/\
-H "Content-Type: application/json" \
-H "Token: 4202c0abe0abd84bf2ab16a717e071d950998ce1"

Request using Java source code:

public void printAccessTokenInfo() {

    Client client = ClientBuilder.newClient();
    WebTarget target =
        client.target( MSP_URL ).path( "/api/public/v3.1/access-tokens" );
    Response response =
        target.request().header( "token", MSP_TOKEN )
              .get( Response.class );

    if ( response.getStatus() == 200 ) {
          System.out.println( response.readEntity( String.class ) );
    } else {
          System.out.println( response.readEntity( String.class ) );
    }
    client.close();
}

Response:

Status: 200

Response Body:

{
    "accessTokens" : [
        {
            "id": "TOKEN_1009113696",
            "issuedTo": "USER_1378343376",
            "type": "SCRIPT",    
            "userName": "cedar_ops", 
            "applicationName": "MS-Portal",  
            "expiresAt": "2019-05-15T11:00:58Z",  
            "issuedAt": "2019-05-15T09:20:58Z",  
            "active": false, 
            "revoked": false,
            "allowedIpRange": "11.2.0.0/11,100.0.2.45/30"  
        },
        {
            "id": "TOKEN_1009995230",  
            "issuedTo": "USER_1378343376", 
            "type": "SCRIPT", 
            "userName": "cedar_ops",  
            "applicationName": "MS-Portal", 
            "expiresAt": "2019-04-02T18:40:18Z", 
            "issuedAt": "2019-04-02T18:39:40Z",  
            "active": false, 
            "revoked": true,
            "allowedIpRange": "11.2.0.0/11,100.0.2.45/30"
    }
    ],
    total: 2
}

Parent topic:Retrieve All Tokens