mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-02 01:16:15 +01:00
Add with_sub method for ServiceAccountKey - required to read email from user accounts
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1,6 +1,6 @@
|
||||
[root]
|
||||
name = "yup-oauth2"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
dependencies = [
|
||||
"base64 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
||||
@@ -158,6 +158,7 @@ pub struct ServiceAccountAccess<C> {
|
||||
client: C,
|
||||
key: ServiceAccountKey,
|
||||
cache: MemoryStorage,
|
||||
sub: Option<String>,
|
||||
}
|
||||
|
||||
/// This is the schema of the server's response.
|
||||
@@ -192,11 +193,23 @@ impl<'a, C> ServiceAccountAccess<C>
|
||||
client: client,
|
||||
key: key,
|
||||
cache: MemoryStorage::default(),
|
||||
sub: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_sub(key: ServiceAccountKey, client: C, sub: Option<String>) -> ServiceAccountAccess<C> {
|
||||
ServiceAccountAccess {
|
||||
client: client,
|
||||
key: key,
|
||||
cache: MemoryStorage::default(),
|
||||
sub: sub,
|
||||
}
|
||||
}
|
||||
|
||||
fn request_token(&mut self, scopes: &Vec<&str>) -> result::Result<Token, Box<error::Error>> {
|
||||
let signed = try!(JWT::new(init_claims_from_key(&self.key, scopes))
|
||||
let mut claims = init_claims_from_key(&self.key, scopes);
|
||||
claims.sub = self.sub.clone();
|
||||
let signed = try!(JWT::new(claims)
|
||||
.sign(self.key.private_key.as_ref().unwrap()));
|
||||
|
||||
let body = form_urlencoded::serialize(vec![("grant_type".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user