mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-02-23 15:50:00 +01:00
Simplify with_storage interface
By only allowing a custom storage. To use one of the built-in storage mechanism, there is already a special-purpose `persist_tokens_to_disk` method available.
This commit is contained in:
@@ -74,11 +74,9 @@ async fn main() {
|
||||
sec,
|
||||
yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||||
)
|
||||
.with_storage(yup_oauth2::authenticator::StorageType::Custom(Box::new(
|
||||
ExampleTokenStore {
|
||||
store: RwLock::new(vec![]),
|
||||
},
|
||||
)))
|
||||
.with_storage(Box::new(ExampleTokenStore {
|
||||
store: RwLock::new(vec![]),
|
||||
}))
|
||||
.build()
|
||||
.await
|
||||
.expect("InstalledFlowAuthenticator failed to build");
|
||||
|
||||
@@ -238,9 +238,9 @@ impl<C, F> AuthenticatorBuilder<C, F> {
|
||||
}
|
||||
|
||||
/// Use the provided token storage mechanism
|
||||
pub fn with_storage(self, storage_type: StorageType) -> Self {
|
||||
pub fn with_storage(self, storage: Box<dyn TokenStorage>) -> Self {
|
||||
AuthenticatorBuilder {
|
||||
storage_type: storage_type,
|
||||
storage_type: StorageType::Custom(storage),
|
||||
..self
|
||||
}
|
||||
}
|
||||
@@ -504,7 +504,7 @@ where
|
||||
}
|
||||
|
||||
/// How should the acquired tokens be stored?
|
||||
pub enum StorageType {
|
||||
enum StorageType {
|
||||
/// Store tokens in memory (and always log in again to acquire a new token on startup)
|
||||
Memory,
|
||||
/// Store tokens to disk in the given file. Warning, this may be insecure unless you configure your operating system to restrict read access to the file.
|
||||
|
||||
Reference in New Issue
Block a user