getToken
codebolt.tokenizer.getToken(key: string): Promise<GetTokenResponse>
Retrieves a token by its key from the system.
Parameters
Name | Type | Description |
---|---|---|
key | string | The key associated with the token to be retrieved. |
Returns:
Promise<GetTokenResponse>
A promise that resolves with the token response.Response Structure
{
type: 'getTokenResponse',
token: string // The original token key/value
}
Example
import codebolt from '@codebolt/codeboltjs';
async function getTokenExample() {
try {
const response = await codebolt.tokenizer.getToken("api_key_1");
console.log("Token retrieved:", response);
// Output: {
// type: 'getTokenResponse',
// token: 'api_key_1'
// }
} catch (error) {
console.error("Failed to retrieve token:", error);
}
}
getTokenExample();