[][src]Function goauth::get_token_blocking

pub fn get_token_blocking(
    jwt: &Jwt<JwtClaims>,
    credentials: &Credentials
) -> 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::credentials::Credentials;
use goauth::get_token_blocking;
use smpl_jwt::Jwt;

fn main() {

  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_blocking(&jwt, &credentials) {
    Ok(x) => debug!("{}", x),
    Err(e) => debug!("{}", e)
  };
}