WeComAccessTokenProvider
public final class WeComAccessTokenProvider
io/agentscope/extensions/channel/wecom/WeComAccessTokenProvider.java:36–118WeCom 访问令牌提供者,把智能体接入外部消息渠道与企业平台。位于 io.agentscope.extensions.channel.wecom 包。核心成员包括 token、invalidate、WeComAccessTokenProvider。
Fetches and caches a WeCom access_token for one corpid + corpsecret pair.
Tokens are valid for ~7200 s; this provider proactively refreshes at ~80% of TTL so a single
worker hot path never sees a forced refresh.
The cache defaults to a process-local InMemoryAccessTokenStore; pass a
shared-storage AccessTokenStore to share tokens across instances.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public WeComAccessTokenProvider(String apiBase, String corpId, String secret) | 初始化 `WeComAccessTokenProvider` 实例。 Creates a new instance. |
public WeComAccessTokenProvider(String apiBase, String corpId, String secret, AccessTokenStore store) | 初始化 `WeComAccessTokenProvider` 实例。 Constructor variant that lets the application choose where the token is cached — for
example a shared-storage `AccessTokenStore` so one refresh or invalidation serves
all instances. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Mono<String> token() | 返回令牌。 Returns a valid access token, refreshing in-band when the cached one is missing or close to
expiring. |
public void invalidate() | 执行 `invalidate` 方法。 Forces the next `#token()` call to refresh. |
构造器详情Constructor Detail
WeComAccessTokenProvider
public WeComAccessTokenProvider(String apiBase, String corpId, String secret)
初始化 WeComAccessTokenProvider 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiBase | String | API 基类(类型 `String`)。The api base. |
corpId | String | corp 标识(类型 `String`)。The corp id. |
secret | String | 密钥(类型 `String`)。The secret. |
io/agentscope/extensions/channel/wecom/WeComAccessTokenProvider.java:45–47WeComAccessTokenProvider
public WeComAccessTokenProvider(String apiBase, String corpId, String secret, AccessTokenStore store)
初始化 WeComAccessTokenProvider 实例。
Constructor variant that lets the application choose where the token is cached — for example a shared-storage AccessTokenStore so one refresh or invalidation serves all instances.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiBase | String | API 基类(类型 `String`)。The api base. |
corpId | String | corp 标识(类型 `String`)。The corp id. |
secret | String | 密钥(类型 `String`)。The secret. |
store | AccessTokenStore | 存储实例(类型 `AccessTokenStore`)。cache for the fetched token; must be thread-safe |
io/agentscope/extensions/channel/wecom/WeComAccessTokenProvider.java:56–62方法详情Method Detail
token
public Mono<String> token()
返回令牌。
Returns a valid access token, refreshing in-band when the cached one is missing or close to expiring.
Mono<String>io/agentscope/extensions/channel/wecom/WeComAccessTokenProvider.java:68–74invalidate
public void invalidate()
执行 invalidate 方法。
Forces the next #token() call to refresh.
io/agentscope/extensions/channel/wecom/WeComAccessTokenProvider.java:115–117