Create Access Tokens

Create a new Access Token using your email and password. Be sure to save the returned Access Token either 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 Access Token in the Catalytic Web App and copy or download it to use in your app. See Authentication for details.

Method Signature

create(string $domain, string $email, string $password, string $name = null): AccessToken

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
$namestringOptional The name to apply to the new Access Token, which will be visible when managing your Access Tokens via the Catalytic Web App
returnsAccessTokenThe newly created Access Token

Example

<?php

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

require_once(__DIR__ . '/vendor/autoload.php');

use Catalytic\SDK\CatalyticClient;
use Catalytic\SDK\Search\Where;

$catalytic = new CatalyticClient();

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

// Save a file with the token to ~/.catalytic/default
$user = posix_getpwuid(posix_getuid());
$file = new SplFileObject($user['dir'], 'w');
$file->fwrite($accessToken->getToken());

// 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

createWithWebApprovalFlow(string $domain, string $name = null): AccessToken

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

<?php

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

require_once(__DIR__ . '/vendor/autoload.php');

use Catalytic\SDK\CatalyticClient;
use Catalytic\SDK\Search\Where;

$catalytic = new CatalyticClient();

$accessToken = $catalytic->accessTokens()->createWithWebApprovalFlow(
		"your-team.pushbot.com");

$approvalUrl = $catalytic->accessTokens()->getApprovalUrl($accessToken);

// A human will need to approve the Access Token
$catalytic->accessTokens()->waitForApproval($accessToken);

// Save a file with the token to ~/.catalytic/default
$user = posix_getpwuid(posix_getuid());
$file = new SplFileObject($user['dir'], 'w');
$file->fwrite($accessToken->getToken());

// 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 GetApprovalUrl Method

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

Method Signature

getApprovalUrl(AccesssToken $accessToken, string $applicationName = "Catalytic SDK"): string

Parameters

ParameterTypeDescription
$accessTokenAccessTokenThe Access Token returned from CreateWithWebApprovalFlow()
$applicationNamestringThe name used on the approval url

The WaitForApproval Method

Wait for the Access Token created with CreateWithWebApprovalFlow to be approved by the user in the Catalytic Web App. This method will complete as soon as the user logs in to their Catalytic team and approves the Access Token request. Be sure to save the returned Access Token by saving $accessToken->getToken() to a custom storage system.

Method Signature

waitForApproval(AccessToken $accessToken, int $waitTimeMillis = null): AccessToken

Parameters

ParameterTypeDescription
$accessTokenAccessTokenThe Access Token returned from CreateWithWebApprovalFlow()
$waitTimeMillisintOptional number of milliseconds to wait before timing out
returnsAccessTokenThe approved Access Token