Who is this article for?
CrashPlan for Small Business, no.
Code42 for Enterprise, yes.
Link: Product plans and features.
This article applies to on-premises authority servers.
Other available versions:
Most requests to the Code42 API must be authenticated. This article describes the available Code42 API authentication methods and provides examples of their use.
The examples in this article use curl, but the concepts apply to other tools that can be used to interact with the Code42 API.
The Code42 API documentation viewers are publicly available. You can see them in a browser without signing in. But the API resources themselves only work for you under these conditions:
- You have a product plan that includes access to the Code42 API.
- Your credentials rely on local authentication. SSO or authentication through any third-party provider will not work.
- Your role provides permission to access the data necessary to a given API resource. For example, if you do not have permission to change device settings in the Code42 console, then you don't have permission to change device settings with the API.
If your API calls fail because you do not have permission to use them, you will see reply messages like these:
- HTTP 401 Unauthorized
- HTTP 401 Could not authenticate user
- Your Code42 product plan does not permit use of the Code42 API.
Comparison of Code42 API authentication methods
The Code42 API offers the following authentication methods:
- Basic: You provide your username and password to authenticate each API request.
- Token: You obtain a temporary authentication token that is good for 30 minutes and use it to authenticate API requests.
The following table describes the advantages and disadvantages of each authentication method:
|Basic||Simple to use.||
More complex to use.
Use basic authentication
Use basic authentication for any version 1 or 4 resource, and version 3's /auth/jwt resource. To use basic authentication, include your Code42 username in the API request and supply your password when prompted.
curl -u "username" https://authority-server.example.com:4285/api/Computer
Use token authentication
Use the same /v3/auth/jwt token to request any API resource of any version.
All version 3 resources require token authentication, except the /v3/auth/jwt resource.
Step 1: Get the token
- Include your Code42 username in a GET request to auth/jwt and supply your password when prompted.
curl -u "username" https://authority-server.example.com:4285/c42api/v3/auth/jwt?useBody=true
- From the reply, copy the value of the v3_user_token. In the example below, it is
Step 2: Use the token in API requests
Include that token in API requests. For example:
tkn="eyJjdHki...txd546Eg" curl --header 'Authorization: v3_user_token '$tkn https://authority-server.example.com:4285/api/User curl --header 'Authorization: v3_user_token '$tkn https://authority-server.example.com:4285/c42api/v3/org/<organizationID>/user curl -H 'Authorization: v3_user_token '$tkn https://authority-server.example.com:4285/api/v4/role/view