kristenlk / oauth2-marketo
PHP League's OAuth2-Client 的 Marketo OAuth 2.0 支持
v1.5
2016-10-03 14:32 UTC
Requires
- php: >=5.5.0
- league/oauth2-client: ^1.0
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ~2.0
This package is not auto-updated.
Last update: 2024-09-18 21:08:41 UTC
README
此包为 PHP League 的 OAuth 2.0 客户端 提供Marketo OAuth 2.0 支持。
安装
要安装,请使用 composer
composer require kristenlk/oauth2-marketo
使用方法
使用方法与 The League 的 OAuth 客户端相同,使用 \Kristenlk\OAuth2\Client\Provider\Marketo
作为提供者。
授权码流程
Marketo 的 REST API 使用两腿 OAuth 2.0 进行认证。我们不需要将 redirectUri 传递给提供者,但我们需要包含一个将用于请求访问令牌的基本 URL。
<?php $provider = new \Kristenlk\OAuth2\Client\Provider\Marketo([ 'clientId' => '{marketo-client-id}', 'clientSecret' => '{marketo-client-secret}', 'baseUrl' => 'https://your-base-url.mktorest.com' ]); // Try to get an access token (using the client credentials grant) $token = $provider->getAccessToken('client_credentials'); // Use this to interact with an API on the users behalf echo $token->getToken();
如果访问令牌过期,我们只需再次调用 getAccessToken()。
测试
$ ./vendor/bin/phpunit
贡献
请参阅 CONTRIBUTING 以获取详细信息。
致谢
许可协议
MIT 许可协议 (MIT)。有关更多信息,请参阅 许可文件。