Skip to content

generateToken

Used for generating a new Bearer token, if enabled. By default, this method will automatically updates the auth property. Learn more about Cobalt sessions.

ts
generateToken(turnstileResponse: string, updateAuth = true): Promise<CobaltSession | CobaltError>

Parameters:

NameTypeDescription
turnstileResponsestringCloudflare Turnstile response
updateAuth default: truebooleanWether it updates the auth property

Returns: Promise<CobaltSession|CobaltError>

Example:

ts
let res = await cobalt.generateToken(turnstileResponse);
if(res.status == 'success') console.log(res.token);