Skip to content

ServiceTitan OAuth 2.0 Client Provider for The PHP League OAuth2-Client

License

Notifications You must be signed in to change notification settings

compwright/oauth2-servicetitan

Repository files navigation

ServiceTitan Provider for OAuth 2.0 Client

Latest Version Total Downloads

This package provides ServiceTitan OAuth 2.0 support for the PHP League's OAuth 2.0 Client.

Installation

To install, use composer:

composer require compwright/oauth2-servicetitan league/oauth2-client

Usage

Create the provider instance using the \Compwright\OAuth2\Servicetitan\ServicetitanProviderFactory factory class.

Example: Authorization Code Flow

$factory = new Compwright\OAuth2\Servicetitan\ServicetitanProviderFactory();
$provider = $factory->new(
    clientId: null,     // optional, recommended to pass as an option to getAccessToken()
    clientSecret: null, // optional, recommended to pass as an option to getAccessToken()
    sandbox: false,     // enable for sandbox environment
    enterprise: false   // enable for Enterprise Hub clients
);

// Get an access token using the authorization code grant
$token = $provider->getAccessToken('client_credentials', [
    'client_id'     => '{servicetitan-client-id}',
    'client_secret' => '{servicetitan-client-secret}',

    // required for Enterprise Hub clients:
    'tenant'        => '{servicetitan-tenant-id}',
]);

// Use the token to interact with an API on the users behalf
echo $token->getToken();

Testing

$ make test

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

ServiceTitan OAuth 2.0 Client Provider for The PHP League OAuth2-Client

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published