Create Access Token

Create a new Access Token using your email and password. Be sure to save the returned Access Token by saving accessToken.getToken() to a custom storage system.

🚧

Not Supported with SSO

If your team is configured with SSO, you will not have a password for Catalytic and therefore cannot use this method to create Access Tokens. Instead, use the CreateWithWebApprovalFlow method, or create a new token in the Catalytic Web App and copy or download it to use in your app. See Authentication for details.

Method Signature

AccessToken create(String teamName, String email, String password);
AccessToken create(String teamName, String email, String password, String name);

Parameters

ParameterTypeDescription
teamNameStringThe name or hostname you use to log in to your Catalytic team. This will typically be <your-team-name>.pushbot.com
emailStringThe email address you use to log in to Catalytic
passwordStringThe password you use to log in to Catalytic
nameStringThe name to apply to the new Access Token, which will be visible when managing your Access Token via the Catalytic Web App
returnsAccessTokenThe newly created Access Token

Example

/*
 * This example demonstrates creating a new Access Token using your
 * email and password
 */

import org.catalytic.sdk.CatalyticClient;
import org.catalytic.sdk.entities.AccessToken;

public class Program {
  
    public static void main(String[] args) throws Exception {

        CatalyticClient catalytic = new CatalyticClient();

      	AccessToken accessToken = catalytic.accessTokens().create(
                "your-team.pushbot.com",
                "your-email",
                "your-password");

        // Save a file with the token to ~/.catalytic/tokens/default     
        List<String> lines = Arrays.asList(accessToken.getToken());
        Path file = Paths.get(System.getProperty("user.home"));
        Files.write(file, lines, StandardCharsets.UTF_8);

        // You are now authenticated and ready to use the Catalytic SDK
        // The above only needs to be done once. Now that your Access Token
        // is saved as the default Access Token, you can configure the SDK
        // to use those:
        catalytic = new CatalyticClient();
    }
}

The CreateWithWebApprovalFlow Method

Create a new Access Token and approve them by logging into your Catalytic account. This method works both for teams with and without SSO enabled. See Authentication for details.

Method Signature

AccessToken createWithWebApprovalFlow(String teamName);
AccessToken createWithWebApprovalFlow(String teamName, String name);

Parameters

ParameterTypeDescription
teamNameStringThe name or hostname you use to log in to your Catalytic team. This will typically be
<your-team-name>.pushbot.com
nameStringA descriptive name to associate with the new Access Token
returnsAccessTokenThe newly created Access Token

Example

/*
 * This example demonstrates creating a new Access Token using tbe
 * web approval flow
 */

import org.catalytic.sdk.CatalyticClient;
import org.catalytic.sdk.entities.AccessToken;

public class Program {
  
    public static void main(String[] args) throws Exception {

        CatalyticClient catalytic = new CatalyticClient();
        AccessToken accessToken = catalytic.accessTokens().createWithWebApprovalFlow("your-team.pushbot.com");

      	// A human will need to approve the Access Token via this url.
        // Once the approval is complete, we can then use that token
        String approvalUrl = catalytic.accessTokens().getApprovalUrl(accessToken);

      	// Save a file with the token to ~/.catalytic/tokens/default     
        List<String> lines = Arrays.asList(accessToken.getToken());
        Path file = Paths.get(System.getProperty("user.home"));
        Files.write(file, lines, StandardCharsets.UTF_8);;

        // You are now authenticated and ready to use the Catalytic SDK
        // The above only needs to be done once. Now that your Access Token
        // is saved as the default Access Token dir, you can configure the SDK
        // to use those:
        catalytic = new CatalyticClient();
    }
}

The GetApprovalUrl Method

Gets the URL that the user must visit to approve Access Tokens created with CreateWithWebApprovalFlow.

String getApprovalUrl(AccessToken accessToken);
String getApprovalUrl(AccessToken accessToken, String applicationName);
ParameterTypeDescription
accessTokenAccess TokenThe Access Token returned from createWithWebApprovalFlow()
applicationNameStringThe name used on the approval url`
returnsStringThe url used to approve the Access Token