Expand description
§OpenLark 认证模块
OpenLark SDK的认证和授权模块,提供飞书开放平台的完整认证解决方案。
§功能特性
- 令牌管理: 自动处理访问令牌的获取、刷新和缓存
- 多种认证方式: 支持企业自建应用、应用商店应用和用户认证
- OAuth支持: 完整的OAuth 2.0授权流程
- 类型安全: 基于Rust类型系统的API设计
- 错误处理: 统一的错误处理和用户友好的错误消息
- 异步支持: 基于tokio的全异步API设计
§模块组织
§快速开始
use openlark_auth::{AuthService, AuthenService, OAuthService};
use openlark_core::config::Config;
let config = Config::builder()
.app_id("your_app_id")
.app_secret("your_app_secret")
.base_url("https://open.feishu.cn")
.build();
// 企业自建应用认证(这里只演示构建请求,不发送网络请求)
let auth_service = AuthService::new(config.clone());
let _token_builder = auth_service
.v3()
.app_access_token_internal()
.app_id("your_app_id")
.app_secret("your_app_secret");
// 用户认证(这里只演示构建请求,不发送网络请求)
let authen_service = AuthenService::new(config.clone());
let _user_info_builder = authen_service
.v1()
.user_info()
.get()
.user_access_token("user_token");
// OAuth(构建授权链接)
let oauth_service = OAuthService::new(config);
let _auth_url = oauth_service
.old()
.authorization()
.app_id("your_app_id")
.redirect_uri("https://example.com/callback")
.build_url();Re-exports§
pub use services::AuthService;pub use services::AuthenService;pub use services::OAuthService;pub use token_provider::AuthTokenProvider;
Modules§
- auth
- 认证主模块
- common
- OpenLark Auth 公共模块
- human_
authentication - 实名认证模块
- models
- 数据模型定义
- passport
- Passport API 模块 (meta.project=passport)
- prelude
- 认证模块的预导入,包含最常用的类型和特征
- services
- 核心认证服务
- token_
provider - openlark-auth 的 TokenProvider 实现
- verification
- 企业认证信息模块
- verification_
information - 企业认证信息模块
Constants§
- VERSION
- 认证模块版本信息