ibmcloud-core

Crates.ioibmcloud-core
lib.rsibmcloud-core
version0.0.1
sourcesrc
created_at2021-04-27 02:38:43.629837
updated_at2021-05-08 19:46:23.960756
descriptionThis crate for IBM Cloud is an abstraction from de api referenced in docs.
homepage
repositoryhttps://github.com/IBM/ibmcloud-core
max_upload_size
id389985
size16,026
Rogério Ferreira (rogeriob2br)

documentation

README

IBM Cloud Core SDK

Rust

This crate is an abstraction from de api referenced in docs.

The first abstraction is about the Identity Manager: https://cloud.ibm.com/apidocs/iam-identity-token-api.json

Single implementation of Authenticate with Token and API key:

Dependencies

#Cargo.toml
[dependencies]
tokio = { version = "1", features = ["full"] }
ibmcloud-core = "0.1.2"

Main.rs

//src/main.rs
use ibmcloud_core::authenticators::token_api::{
    AuthenticatorApiClient, ResponseType, TokenResponse,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // You Atuhenticator Client
    // Need change your api-key
    let mut auth = AuthenticatorApiClient::new("<YOUR-API-key>".to_string());

    // This turn your client authenticated
    auth.authenticate().await?;
    println!("{:?}", auth.clone());
    
    // If you need to get token, this is the best choice. 
    // This feature manages the life cycle of your token.
    let token = auth.get_token();
    Ok(())
}

Commit count: 48

cargo fmt