wotta / oauth2-hubspot
为 PHP League OAuth2-Client 包提供 HubSpot OAuth 2 客户端提供者
v1.0.3
2021-08-17 12:07 UTC
Requires
- league/oauth2-client: ^2.0
Requires (Dev)
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: ^3.5
README
本软件包为 PHP League 的 OAuth 2.0 客户端 提供了 HubSpot OAuth 2.0 支持。
安装
要安装,请使用 composer
composer require helpscout/oauth2-hubspot
用法
用法与 The League 的 OAuth 客户端相同,使用 \HelpScout\OAuth2\Client\Provider\HubSpot
作为提供者。
授权码流程
$provider = new HelpScout\OAuth2\Client\Provider\HubSpot([ 'clientId' => '{hubspot-client-id}', 'clientSecret' => '{hubspot-client-secret}', 'redirectUri' => 'https://example.com/callback-url' ]);
有关本软件包的进一步用法,请参阅 核心软件包文档中的“授权码授予”部分。
刷新令牌
$provider = new HelpScout\OAuth2\Client\Provider\HubSpot([ 'clientId' => '{hubspot-client-id}', 'clientSecret' => '{hubspot-client-secret}', 'redirectUri' => 'https://example.com/callback-url' ]); $existingAccessToken = getAccessTokenFromYourDataStore(); if ($existingAccessToken->hasExpired()) { $newAccessToken = $provider->getAccessToken('refresh_token', [ 'refresh_token' => $existingAccessToken->getRefreshToken() ]); // Purge old access token and store new access token to your data store. }
有关本软件包的进一步用法,请参阅 核心软件包文档中的“刷新令牌”部分。
测试
$ ./vendor/bin/phpunit
贡献
有关详细信息,请参阅 CONTRIBUTING。
鸣谢
许可
MIT 许可证(MIT)。有关更多信息,请参阅 许可文件。