neclimdul/oauth2-marketo

为 PHP League 的 OAuth2-Client 提供 Marketo OAuth 2.0 支持

v2.0.3 2022-03-25 20:37 UTC

This package is auto-updated.

Last update: 2024-09-26 01:53:37 UTC


README

Software License

本包为 PHP League 的 OAuth 2.0 客户端 提供Marketo OAuth 2.0 支持。

本包基于 https://github.com/kristenlk/oauth2-marketo,主要更新以支持依赖项的新版本。

安装

要安装,请使用 composer

composer require neclimdul/oauth2-marketo

使用方法

使用方法与 The League 的 OAuth 客户端相同,使用 \NecLimDul\OAuth2\Client\Provider\Marketo 作为提供者。

授权码流

Marketo 的 REST API 使用双端 OAuth 2.0 进行认证。我们不需要向提供者传递 redirectUri,但我们需要包含一个用于请求访问令牌的基础 URL。

<?php
$provider = new \NecLimDul\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)。有关更多信息,请参阅 许可文件