Skip to content
LogoLogo

Get Zone Authorization Token Info

zone.getAuthorizationTokenInfo

Returns the authenticated account address and token expiry from the current authorization token.

Usage

import {  } from './viem.config'
 
const  = await ..()
 
.('Account:', .)
.('Expires At:', .)
Account: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb
Expires At: 1717027200n

Recipes

Re-Sign Before the Token Expires

Combine the token expiry with zone.signAuthorizationToken to refresh authentication in a long-running service before zone requests start failing.

import {  } from './viem.config'
 
const {  } = await ..()
 
const  = 60n * 60n
const  = (.(.() / 1000))
 
if ( -  < )
  await ..()

Return Value

type ReturnType = {
  /** Authenticated account address. */
  account: Address
  /** Token expiry as a unix timestamp. */
  expiresAt: bigint
}

The authorization token info.