/auth/v2/token

login compatible with BCS payload with intent bytes

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

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

Query Params
int64
Defaults to 2592000

The number of seconds the refresh token is valid for. If not provided, the default is 30 days.

boolean
Defaults to false

If not supplied defaults to false

Body Params

User is expected to sign this payload and sends is signature in login api as header and payload itself in request body

string
required

The address of the account.

int64
required

The timestamp in millis when the login was signed.

string
required

The intended audience of the login request.

Headers
string
required
Responses

Language
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json