mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-17 16:07:11 +01:00
docs(helpers): Let service account and helper code show up in rustdoc
This commit is contained in:
@@ -11,20 +11,23 @@ use serde_json;
|
||||
|
||||
use std::io::{self, Read};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
use service_account::ServiceAccountKey;
|
||||
use types::{ConsoleApplicationSecret, ApplicationSecret};
|
||||
|
||||
pub fn read_application_secret(file: &String) -> io::Result<ApplicationSecret> {
|
||||
/// Read an application secret from a file.
|
||||
pub fn read_application_secret(path: &Path) -> io::Result<ApplicationSecret> {
|
||||
use std::io::Read;
|
||||
|
||||
let mut secret = String::new();
|
||||
let mut file = try!(fs::OpenOptions::new().read(true).open(file));
|
||||
let mut file = try!(fs::OpenOptions::new().read(true).open(path));
|
||||
try!(file.read_to_string(&mut secret));
|
||||
|
||||
parse_application_secret(&secret)
|
||||
}
|
||||
|
||||
/// Read an application secret from a JSON string.
|
||||
pub fn parse_application_secret(secret: &String) -> io::Result<ApplicationSecret> {
|
||||
let result: serde_json::Result<ConsoleApplicationSecret> = serde_json::from_str(secret);
|
||||
match result {
|
||||
@@ -45,6 +48,8 @@ pub fn parse_application_secret(secret: &String) -> io::Result<ApplicationSecret
|
||||
}
|
||||
}
|
||||
|
||||
/// Read a service account key from a JSON file. You can download the JSON keys from the Google
|
||||
/// Cloud Console or the respective console of your service provider.
|
||||
pub fn service_account_key_from_file(path: &String) -> io::Result<ServiceAccountKey> {
|
||||
let mut key = String::new();
|
||||
let mut file = try!(fs::OpenOptions::new().read(true).open(path));
|
||||
|
||||
@@ -31,3 +31,4 @@ pub use authenticator::{Authenticator, Retry, GetToken};
|
||||
pub use authenticator_delegate::{AuthenticatorDelegate, DefaultAuthenticatorDelegate, PollError,
|
||||
PollInformation};
|
||||
pub use helper::*;
|
||||
pub use service_account::*;
|
||||
|
||||
Reference in New Issue
Block a user