Crates.io | google-jwt-auth |
lib.rs | google-jwt-auth |
version | 0.1.0 |
source | src |
created_at | 2023-10-24 13:02:22.903594 |
updated_at | 2023-11-15 19:01:04.2073 |
description | Generate authentication tokens for Google api requests |
homepage | |
repository | https://github.com/kronos-et-al/google-jwt-auth |
max_upload_size | |
id | 1012342 |
size | 85,083 |
Generate authentication tokens for Google api requests.
See Using OAuth 2.0 for Server to Server Applications for a description of the procedure.
To obtain a token, some tasks need to be done:
This json file is important and necessary to use this crate. See in Examples/Usage its usage.
Each token request has a lifetime. This lifetime need to be provided as param in seconds. Allowed are values between 30 to 3600.
The next updates take care of the following:
...
let config = AuthConfig::build( //<-- Config can be reused
fs::read_to_string("service_account.json").unwrap(), //<-- JSON as string
&Usage::CloudVision, //<-- Api-Usage
).unwrap();
let token = config.generate_auth_token(3600).await.unwrap(); //<-- Generate token
println!("{}", token);
...
This chapter should help to determine who/which causes the problem and how to fix it:
LibError | Type | Solution (not guaranteed) |
---|---|---|
AuthenticationError | invalid_grant | Your service-client.json is no longer valid as the key got deleted in the google console. Replace this file with a new one by generating a new key. |
This table is WIP and will change if new errors occur or someone requests a related issue.