Who is this article for?
CrashPlan for Small Business, no.
Code42 for Enterprise, yes.
Link: Product plans and features.
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.
In addition, the examples in this article use resource https://www.crashplan.com, but the resource you use depends on your Code42 cloud address:
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 administration console, then you don't have permission to change device settings with the API.
The Code42 API and the documentation viewers are built to serve both the Code42 cloud and on-premises Code42 environments.
Customers using the Code42 cloud will see documentation about API resources that to do not apply to the Code42 cloud. For example:
- Resources for managing LDAP.
- Resources for managing storage server.
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. Token authentication is required if your organization uses two-factor authentication for local users. If two-factor authentication is not enabled, you have the choice to use token authentication for any API request.
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 and later 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://www.crashplan.com/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://www.crashplan.com/c42api/v3/auth/jwt?useBody=true
If your organization uses two-factor authentication for local users, you must also include a totp-auth header value containing the six- to eight-digit Time-based One-Time Password (TOTP) supplied by the Google Authenticator mobile app. (Sending the request without the TOTP displays the error message
TIME_BASED_ONE_TIME_PASSWORD_REQUIRED.) The example below includes a TOTP value of 424242.
curl -u "username" -H "totp-auth: 424242" https://www.crashplan.com/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://www.crashplan.com:4285/api/User curl --header 'Authorization: v3_user_token '$tkn https://www.crashplan.com:4285/c42api/v3/org/<organizationID>/user curl -H 'Authorization: v3_user_token '$tkn https://www.crashplan.com/api/v4/role/view