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
Parameter | Type | Description |
---|---|---|
teamName | String | The name or hostname you use to log in to your Catalytic team. This will typically be <your-team-name>.pushbot.com |
email | String | The email address you use to log in to Catalytic |
password | String | The password you use to log in to Catalytic |
name | String | The name to apply to the new Access Token, which will be visible when managing your Access Token via the Catalytic Web App |
returns | AccessToken | The 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
Parameter | Type | Description |
---|---|---|
teamName | String | The name or hostname you use to log in to your Catalytic team. This will typically be<your-team-name>.pushbot.com |
name | String | A descriptive name to associate with the new Access Token |
returns | AccessToken | The 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);
Parameter | Type | Description |
---|---|---|
accessToken | Access Token | The Access Token returned from createWithWebApprovalFlow() |
applicationName | String | The name used on the approval url` |
returns | String | The url used to approve the Access Token |
Updated almost 3 years ago