[−][src]Function goauth::get_token_legacy
pub fn get_token_legacy(
jwt: &Jwt<JwtClaims>,
url: Option<&str>
) -> Result<Token>
Get Token which can be used to authenticate further request
Example
extern crate smpl_jwt; extern crate goauth; #[macro_use] extern crate log; use goauth::auth::JwtClaims; use goauth::scopes::Scope; use goauth::get_token_legacy; use smpl_jwt::{RSAKey, Jwt}; fn main() { let token_url = "https://www.googleapis.com/oauth2/v4/token"; let iss = "some_iss"; // https://developers.google.com/identity/protocols/OAuth2ServiceAccount let private_key_file = "random_rsa_for_testing"; let claims = JwtClaims::new(String::from(iss), &Scope::DevStorageReadWrite, String::from(token_url), None, None); let key = match RSAKey::from_pem(private_key_file) { Ok(x) => x, Err(e) => panic!("{}", e) }; let jwt = Jwt::new(claims, key, None); match get_token_legacy(&jwt, None) { Ok(x) => debug!("{}", x), Err(e) => debug!("{}", e) }; }