DingTalkAccessTokenProvider
public final class DingTalkAccessTokenProvider
io/agentscope/extensions/channel/dingtalk/DingTalkAccessTokenProvider.java:40–116DingTalk 访问令牌提供者,把智能体接入外部消息渠道与企业平台。位于 io.agentscope.extensions.channel.dingtalk 包。核心成员包括 token、invalidate、DingTalkAccessTokenProvider。
Fetches and caches a DingTalk OpenAPI accessToken for one appKey + appSecret
pair. Tokens are valid for ~7200 s; this provider proactively refreshes at ~80% of TTL.
Uses the new OpenAPI endpoint POST /v1.0/oauth2/accessToken. The legacy
/gettoken endpoint at oapi.dingtalk.com is not used.
The cache defaults to a process-local InMemoryAccessTokenStore; pass a
shared-storage AccessTokenStore to share tokens across instances.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public DingTalkAccessTokenProvider(String apiBase, String appKey, String appSecret) | 初始化 `DingTalkAccessTokenProvider` 实例。 Creates a new instance. |
public DingTalkAccessTokenProvider(String apiBase, String appKey, String appSecret, AccessTokenStore store) | 初始化 `DingTalkAccessTokenProvider` 实例。 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
DingTalkAccessTokenProvider
public DingTalkAccessTokenProvider(String apiBase, String appKey, String appSecret)
初始化 DingTalkAccessTokenProvider 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiBase | String | API 基类(类型 `String`)。The api base. |
appKey | String | 应用键(类型 `String`)。The app key. |
appSecret | String | 应用密钥(类型 `String`)。The app secret. |
io/agentscope/extensions/channel/dingtalk/DingTalkAccessTokenProvider.java:49–51DingTalkAccessTokenProvider
public DingTalkAccessTokenProvider(String apiBase, String appKey, String appSecret, AccessTokenStore store)
初始化 DingTalkAccessTokenProvider 实例。
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. |
appKey | String | 应用键(类型 `String`)。The app key. |
appSecret | String | 应用密钥(类型 `String`)。The app secret. |
store | AccessTokenStore | 存储实例(类型 `AccessTokenStore`)。cache for the fetched token; must be thread-safe |
io/agentscope/extensions/channel/dingtalk/DingTalkAccessTokenProvider.java:60–66方法详情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/dingtalk/DingTalkAccessTokenProvider.java:72–78invalidate
public void invalidate()
执行 invalidate 方法。
Forces the next #token() call to refresh.
io/agentscope/extensions/channel/dingtalk/DingTalkAccessTokenProvider.java:113–115