mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-02-23 15:50:00 +01:00
Accept scopes as a slice of anything that can produce a &str.
Along with the public facing change the implementation has been modified to no longer clone the scopes instead using the pointer to the scopes the user provided. This greatly reduces the number of allocations on each token() call. Note that this also changes the hashing method used for token storage in an incompatible way with the previous implementation. The previous implementation pre-sorted the vector and hashed the contents to make the result independent of the ordering of the scopes. Instead we now combine the hash values of each scope together with XOR, thus producing a hash value that does not depend on order without needing to allocate another vector and sort.
This commit is contained in:
@@ -12,7 +12,7 @@ async fn main() {
|
||||
.build()
|
||||
.expect("authenticator");
|
||||
|
||||
let scopes = vec!["https://www.googleapis.com/auth/youtube.readonly"];
|
||||
let scopes = &["https://www.googleapis.com/auth/youtube.readonly"];
|
||||
match auth.token(scopes).await {
|
||||
Err(e) => println!("error: {:?}", e),
|
||||
Ok(t) => println!("token: {:?}", t),
|
||||
|
||||
Reference in New Issue
Block a user