Sep06AuthenticationRequiredException

Exception thrown when SEP-6 authentication is required but missing or invalid.

Indicates that the request requires a valid SEP-10 JWT token that is either missing, expired, or invalid. All SEP-6 endpoints except /info require authentication. This error typically occurs when:

  • JWT token is not provided in the Authorization header

  • JWT token has expired

  • JWT token is malformed or tampered with

  • JWT token signature is invalid

  • Token was issued for a different anchor

Recovery actions:

  • Authenticate via SEP-10 WebAuth to obtain a fresh JWT token

  • Verify the token is being sent in the Authorization header

  • Check that the token was issued by the correct anchor

Example - Handle authentication failure:

suspend fun initiateDeposit(
sep06Service: Sep06Service,
webAuth: WebAuth,
assetCode: String,
accountId: String,
keyPair: KeyPair
): Sep06DepositResponse? {
var jwt = getCachedJwt()

try {
return sep06Service.deposit(assetCode, jwt)
} catch (e: Sep06AuthenticationRequiredException) {
println("Authentication required, re-authenticating...")

// Obtain fresh token via SEP-10
val authToken = webAuth.jwtToken(
clientAccountId = accountId,
signers = listOf(keyPair)
)
jwt = authToken.token
cacheJwt(jwt)

// Retry with new token
return sep06Service.deposit(assetCode, jwt)
}
}

See also:

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
expect open val cause: Throwable?
Link copied to clipboard
expect open val message: String?

Functions

Link copied to clipboard
open override fun toString(): String