Class WeComAccessTokenProvider

java.lang.Object
io.agentscope.extensions.channel.wecom.WeComAccessTokenProvider

public final class WeComAccessTokenProvider extends Object
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 Details

    • WeComAccessTokenProvider

      public WeComAccessTokenProvider(String apiBase, String corpId, String secret)
    • WeComAccessTokenProvider

      public WeComAccessTokenProvider(String apiBase, String corpId, String secret, io.agentscope.extensions.channel.common.AccessTokenStore store)
      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:
      store - cache for the fetched token; must be thread-safe
  • Method Details

    • token

      public reactor.core.publisher.Mono<String> token()
      Returns a valid access token, refreshing in-band when the cached one is missing or close to expiring.
    • invalidate

      public void invalidate()
      Forces the next token() call to refresh. Useful for tests / error recovery.