[][src]Function goauth::get_token_with_creds_async

pub fn get_token_with_creds_async(
    jwt: &Jwt<JwtClaims>,
    credentials: &Credentials
) -> impl Future<Item = Result<Token, GOErr>>

Async get Token which can be used to authenticate further request

Example

extern crate smpl_jwt;
extern crate goauth;
#[macro_use]
extern crate log;
extern crate futures;

use goauth::auth::JwtClaims;
use goauth::scopes::Scope;
use goauth::credentials::Credentials;
use goauth::error::GOErr;
use goauth::get_token_with_creds_async;
use smpl_jwt::Jwt;
use futures::future::Future;


fn main() -> Result<(), GOErr> {

  let credentials = Credentials::from_file("dummy_credentials_file_for_tests.json").unwrap();

  let claims = JwtClaims::new(credentials.iss(),
                             &Scope::DevStorageReadWrite,
                             credentials.token_uri(),
                             None, None);

  let jwt = Jwt::new(claims, credentials.rsa_key().unwrap(), None);
  match get_token_with_creds_async(&jwt, &credentials).wait() {
    Ok(x) => debug!("{}", x?),
    Err(_) => error!("An error occurred, somewhere in there, tyr debugging with `get_token_with_creds`")
  };
  Ok(())
}