helpscout / oauth2-hubspot
PHP League OAuth2-Client 包的 HubSpot OAuth 2 客户端提供者
0.2.2
2024-03-14 16:17 UTC
Requires
- league/oauth2-client: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is not auto-updated.
Last update: 2024-09-16 21:51:33 UTC
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)。请参阅 许可文件 了解更多信息。