https://github.com/compwright/oauth2-servicetitan
ServiceTitan OAuth 2.0 Client Provider for The PHP League OAuth2-Client
https://github.com/compwright/oauth2-servicetitan
oauth2-client servicetitan
Last synced: 2 months ago
JSON representation
ServiceTitan OAuth 2.0 Client Provider for The PHP League OAuth2-Client
- Host: GitHub
- URL: https://github.com/compwright/oauth2-servicetitan
- Owner: compwright
- License: mit
- Created: 2022-04-15T20:14:52.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-12-03T18:52:52.000Z (about 1 year ago)
- Last Synced: 2024-12-03T19:36:38.094Z (about 1 year ago)
- Topics: oauth2-client, servicetitan
- Language: PHP
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# ServiceTitan Provider for OAuth 2.0 Client
[](https://github.com/compwright/oauth2-servicetitan/releases)
[](https://packagist.org/packages/compwright/oauth2-servicetitan)
This package provides ServiceTitan OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-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
```php
$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
``` bash
$ make test
```
## Contributing
Please see [CONTRIBUTING](https://github.com/compwright/oauth2-servicetitan/blob/master/CONTRIBUTING.md) for details.
## Credits
- [Jonathon Hill](https://github.com/compwright), [CompWright Enterprises, LLC](https://compwright.com)
## License
The MIT License (MIT). Please see [License File](https://github.com/compwright/oauth2-servicetitan/blob/master/LICENSE) for more information.