AS AgentScopeAPI 手册 / API Reference

DingTalkAccessTokenProvider

public final class DingTalkAccessTokenProvider
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkAccessTokenProvider.java:40–116

DingTalk 访问令牌提供者,把智能体接入外部消息渠道与企业平台。位于 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.

参数Parameters
名称Name类型Type说明Description
apiBaseStringAPI 基类(类型 `String`)。The api base.
appKeyString应用键(类型 `String`)。The app key.
appSecretString应用密钥(类型 `String`)。The app secret.
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkAccessTokenProvider.java:49–51

DingTalkAccessTokenProvider

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.

参数Parameters
名称Name类型Type说明Description
apiBaseStringAPI 基类(类型 `String`)。The api base.
appKeyString应用键(类型 `String`)。The app key.
appSecretString应用密钥(类型 `String`)。The app secret.
storeAccessTokenStore存储实例(类型 `AccessTokenStore`)。cache for the fetched token; must be thread-safe
源码Source 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.

返回Returns Mono<String>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/channel/dingtalk/DingTalkAccessTokenProvider.java:72–78

invalidate

public void invalidate()

执行 invalidate 方法。

Forces the next #token() call to refresh.

源码Source io/agentscope/extensions/channel/dingtalk/DingTalkAccessTokenProvider.java:113–115
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.