Class OAuth2Config.Builder

java.lang.Object
cloud.opencode.base.oauth2.OAuth2Config.Builder
Enclosing class:
OAuth2Config

public static class OAuth2Config.Builder extends Object
OAuth2Config Builder OAuth2Config 构建器
Since:
JDK 25, opencode-base-oauth2 V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • clientId

      public OAuth2Config.Builder clientId(String clientId)
      Set the client ID 设置客户端 ID
      Parameters:
      clientId - the client ID | 客户端 ID
      Returns:
      this builder | 此构建器
    • clientSecret

      public OAuth2Config.Builder clientSecret(String clientSecret)
      Set the client secret 设置客户端密钥
      Parameters:
      clientSecret - the client secret | 客户端密钥
      Returns:
      this builder | 此构建器
    • authorizationEndpoint

      public OAuth2Config.Builder authorizationEndpoint(String authorizationEndpoint)
      Set the authorization endpoint 设置授权端点
      Parameters:
      authorizationEndpoint - the authorization endpoint | 授权端点
      Returns:
      this builder | 此构建器
    • tokenEndpoint

      public OAuth2Config.Builder tokenEndpoint(String tokenEndpoint)
      Set the token endpoint 设置令牌端点
      Parameters:
      tokenEndpoint - the token endpoint | 令牌端点
      Returns:
      this builder | 此构建器
    • userInfoEndpoint

      public OAuth2Config.Builder userInfoEndpoint(String userInfoEndpoint)
      Set the user info endpoint 设置用户信息端点
      Parameters:
      userInfoEndpoint - the user info endpoint | 用户信息端点
      Returns:
      this builder | 此构建器
    • revocationEndpoint

      public OAuth2Config.Builder revocationEndpoint(String revocationEndpoint)
      Set the revocation endpoint 设置撤销端点
      Parameters:
      revocationEndpoint - the revocation endpoint | 撤销端点
      Returns:
      this builder | 此构建器
    • deviceAuthorizationEndpoint

      public OAuth2Config.Builder deviceAuthorizationEndpoint(String deviceAuthorizationEndpoint)
      Set the device authorization endpoint 设置设备授权端点
      Parameters:
      deviceAuthorizationEndpoint - the device authorization endpoint | 设备授权端点
      Returns:
      this builder | 此构建器
    • redirectUri

      public OAuth2Config.Builder redirectUri(String redirectUri)
      Set the redirect URI 设置重定向 URI
      Parameters:
      redirectUri - the redirect URI | 重定向 URI
      Returns:
      this builder | 此构建器
    • scopes

      public OAuth2Config.Builder scopes(String... scopes)
      Set the scopes 设置权限范围
      Parameters:
      scopes - the scopes | 权限范围
      Returns:
      this builder | 此构建器
    • scopes

      public OAuth2Config.Builder scopes(Set<String> scopes)
      Set the scopes from a set 从集合设置权限范围
      Parameters:
      scopes - the scopes | 权限范围
      Returns:
      this builder | 此构建器
    • scope

      public OAuth2Config.Builder scope(String scope)
      Add a scope 添加权限范围
      Parameters:
      scope - the scope | 权限范围
      Returns:
      this builder | 此构建器
    • grantType

      public OAuth2Config.Builder grantType(GrantType grantType)
      Set the grant type 设置授权类型
      Parameters:
      grantType - the grant type | 授权类型
      Returns:
      this builder | 此构建器
    • usePkce

      public OAuth2Config.Builder usePkce(boolean usePkce)
      Enable or disable PKCE 启用或禁用 PKCE
      Parameters:
      usePkce - true to enable PKCE | true 启用 PKCE
      Returns:
      this builder | 此构建器
    • connectTimeout

      public OAuth2Config.Builder connectTimeout(Duration connectTimeout)
      Set the connect timeout 设置连接超时
      Parameters:
      connectTimeout - the connect timeout | 连接超时
      Returns:
      this builder | 此构建器
    • readTimeout

      public OAuth2Config.Builder readTimeout(Duration readTimeout)
      Set the read timeout 设置读取超时
      Parameters:
      readTimeout - the read timeout | 读取超时
      Returns:
      this builder | 此构建器
    • refreshThreshold

      public OAuth2Config.Builder refreshThreshold(Duration refreshThreshold)
      Set the refresh threshold 设置刷新阈值

      Token will be refreshed when remaining time is less than this threshold.

      当剩余时间小于此阈值时将刷新令牌。

      Parameters:
      refreshThreshold - the refresh threshold | 刷新阈值
      Returns:
      this builder | 此构建器
    • build

      public OAuth2Config build()
      Build the OAuth2Config 构建 OAuth2Config
      Returns:
      the config | 配置
      Throws:
      NullPointerException - if clientId is null | 如果 clientId 为 null