Skip to main content

build_auth_header

Function build_auth_header 

Source
pub fn build_auth_header<'f1, 'f2, 'f3, 'f4, 'f5, 'f6>() -> BuildAuthHeaderBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6>
Available on crate features async or blocking only.
Expand description

You probably don’t want to use this function directly, unless you are implementing your own abstraction over the remote.it API.

Create the value to use in the Authorization header for requests to the remote.it API.

This function is used by [R3Client::send_remoteit_graphql_request] and [R3Client::send_remoteit_graphql_request_async] to authorize requests to the remote.it API.

§Returns

A String which should be set as the value for the Authorization header for sending requests to the remote.it API.

§Example

use reqwest::Method;
use remoteit_api::Credentials;
use remoteit_api::GRAPHQL_PATH;
let credentials: Credentials = Credentials::load_from_disk()
    .custom_credentials_path(".env.remoteit")
    .call()
    .expect("Couldn't load credentials!")
    .take_profile("default")
    .expect("Couldn't parse secret access key!")
    .expect("Profile with given name does not exist!");
let date = remoteit_api::auth::get_date();
let auth_header = remoteit_api::auth::build_auth_header()
    .key_id(credentials.access_key_id())
    .key(credentials.key())
    .content_type("application/json")
    .method(&Method::POST)
    .path(GRAPHQL_PATH)
    .date(&date)
    .call();