duocircle/remoteauth-php-sdk

RemoteAuth 的 PHP SDK。

6.0.2 2019-06-01 23:07 UTC

This package is auto-updated.

Last update: 2024-09-08 08:21:32 UTC


README

这个库是调用 RemoteAuth API 的包装器。

工作原理

  • 初始化一个新的 Client 实例。
  • 调用 API 方法时,您必须传递您正在验证的用户的 RemoteAuthUser 实例。
  • 如果访问令牌过期,客户端将自动尝试刷新访问令牌。

客户端初始化

您可以通过传递以下选项来创建一个新的客户端实例:

$client = new Client([
    'baseUrl' => 'https://app.remoteauth.com',
    'clientId' => 'XXX',
    'clientSecret' => 'XXX',
    'scope' => ''
], $cache);

选项

  • baseUrl - 您正在使用的 RemoteAuth 服务器 URL。
  • clientId - 您 OAuth 客户端的 Client ID。这可以从 RemoteAuth UI 中获取。
  • clientSecret - 您 OAuth 客户端的 Client Secret。这也可以从 RemoteAuth UI 中获取。
  • scope - 在刷新访问令牌时希望请求的范围。

$cache 参数

Client 构造函数的第二个参数是一个可选参数,它必须是一个 Psr\SimpleCache\CacheInterface 实例。

方法

客户端公开以下方法。所有方法都必须传递您正在验证的 RemoteAuthUser。对于有效载荷和忽略缓存的请求结果,可选参数。

  • applicationMembersByToken($user, $ignoreCache) - 返回存在于用户与应用程序(通过给定令牌附加)之间的 ApplicationMember 记录。