/auth/v2/token

login compatible with BCS payload with intent bytes

Client Library

use bluefin_api::models::LoginRequest;
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>;


#[tokio::main]
async fn main() -> Result<()> {
    // 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("INSERT_HEX_ENCODED_PRIVATE_KEY_HERE")?,
    )?;

    // Then, we submit our authentication request to the API for the desired environment.
    let auth_token = request
        .authenticate(&signature, Environment::Mainnet)
        .await?
        .access_token;

    println!("auth_token: {auth_token}");

    Ok(())
}

HTTPs

Alternatively, call the POST /auth/v2/token endpoint using the integrated editor on the right or locally from any language supporting HTTPs network calls.

Request & Response

Language
URL
Click Try It! to start a request and see the response here!