put https://auth.api.{env}.bluefin.io/auth/token/refresh
Retrieves a new auth token for an account. Expiry is set to 5 min
Client Library
use bluefin_api::models::{LoginRequest, RefreshTokenRequest, RefreshTokenResponse};
use bluefin_pro::prelude::*;
use chrono::Utc;
use hex::FromHex;
use sui_sdk_types::SignatureScheme;
type Error = Box<dyn std::error::Error>;
type Result<T> = std::result::Result<T, Error>;
async fn refresh_token(refresh_token_request: RefreshTokenRequest, environment: Environment) -> Result<RefreshTokenResponse> {
refresh_token_request
.refresh(environment)
.await
.map_err(|error| error.into())
}
#[tokio::main]
async fn main() -> Result<()> {
let environment = Environment::Mainnet;
// We construct an authentication request to obtain a token.
let request = LoginRequest {
account_address: "INSERT_ACCOUNT_ADDRESS_HERE",
audience: auth::mainnet::AUDIENCE.into(),
signed_at_millis: Utc::now().timestamp_millis(),
};
// Next, we generate a signature for the request.
let signature = request.signature(
SignatureScheme::Ed25519,
PrivateKey::from_hex("HEX_ENCODED_PRIVATE_KEY_HERE")?,
)?;
// Then, we submit our authentication request to the API for the desired environment.
let login_response = request
.authenticate(&signature, environment)
.await?;
let refresh_token_request = RefreshTokenRequest {
refresh_token: login_response.refresh_token.clone(),
};
let refresh_token = refresh_token(refresh_token_request, environment).await?;
println!("{refresh_token:#?}");
Ok(())
}
HTTPs
Alternatively, call the PUT /auth/token/refresh endpoint using the integrated editor on the right or locally from any language supporting HTTPs network calls.