5个版本

0.2.1 2021年4月19日
0.2.0 2021年2月12日
0.1.2 2020年6月28日
0.1.1 2020年5月11日
0.1.0 2020年5月4日

#749 in 身份验证

Download history • Rust 包仓库 485/week @ 2024-03-14 • Rust 包仓库 522/week @ 2024-03-21 • Rust 包仓库 724/week @ 2024-03-28 • Rust 包仓库 904/week @ 2024-04-04 • Rust 包仓库 725/week @ 2024-04-11 • Rust 包仓库 803/week @ 2024-04-18 • Rust 包仓库 588/week @ 2024-04-25 • Rust 包仓库 434/week @ 2024-05-02 • Rust 包仓库 518/week @ 2024-05-09 • Rust 包仓库 893/week @ 2024-05-16 • Rust 包仓库 947/week @ 2024-05-23 • Rust 包仓库 952/week @ 2024-05-30 • Rust 包仓库 661/week @ 2024-06-06 • Rust 包仓库 1194/week @ 2024-06-13 • Rust 包仓库 840/week @ 2024-06-20 • Rust 包仓库 504/week @ 2024-06-27 • Rust 包仓库

3,365 每月下载量
4 个Crates中使用了 (3 直接)

MIT 许可证

27KB
698

gouth

ci Rust Documentation Latest Version

此库为GCP服务身份验证提供自动续订令牌。

说明

身份验证流程 状态
API密钥 不支持 / 没有计划支持
OAuth 2.0客户端 支持
环境提供的服务帐户 支持
服务帐户密钥 支持

示例

默认

  • 作用域是 https://www.googleapis.com/auth/cloud-platform
  • 在以下位置查找凭证,优先查找找到的第一个位置
    • 由环境变量 GOOGLE_APPLICATION_CREDENTIALS 指定路径的JSON文件。
    • 在gcloud命令行工具已知的路径中的JSON文件。
    • 在Google Compute Engine上,它从元数据服务器获取凭证。
// simple:
// gouth = { version = "x.x.x" }
let token = gouth::Token::new().unwrap();
println!("authorization: {}", token.header_value().unwrap());

// with tonic:
// gouth = { path = "x.x.x", features = ["tonic-intercept"] }
let mut service = PublisherClient::with_interceptor(channel, gouth::tonic::interceptor());
service.list_topics(...);

自定义

作用域

use gouth::Builder;

let token = Builder::new()
	.scopes(&["https://www.googleapis.com/auth/bigquery"])
	.build()
	.unwrap();
println!("authorization: {}", token.header_value().unwrap());

json

use gouth::Builder;

let token = Builder::new().json("credentials-data").build().unwrap();
println!("authorization: {}", token.header_value().unwrap());

文件

use gouth::Builder;

let token = Builder::new().file("credentials-path").build().unwrap();
println!("authorization: {}", token.header_value().unwrap());

许可证

MIT许可证 下授权。


lib.rs:

此库为GCP服务身份验证提供自动续订令牌。

示例

use gouth::Token;

let token = Token::new().unwrap();
println!("authorization: {}", token.header_value().unwrap());

依赖关系

~15–20MB
~474K SLoC