Session Management

Get Auth Token

Learn how to retrieve the authorization token using the Okto SDK.

The getAuthorizationToken() method retrieves the current user's authorization token for authenticated operations.

Example

import { useOkto } from '@okto_web3/react-native-sdk';
import { View, Text, Pressable } from 'react-native';
 
function TokenRetrieval() {
    const oktoClient = useOkto();
 
    async function getToken() {
        try {
            const token = await oktoClient.getAuthorizationToken();
            console.log("Auth token retrieved");
        } catch (error) {
            console.error("Failed to get token:", error);
        }
    }
 
    return (
        <View>
            <Pressable onPress={getToken}>
                <Text>Get Auth Token</Text>
            </Pressable>
        </View>
    );
}

Method Overview

MethodsDescription
async OktoClient.getAuthorizationTokenGet the current authorization token

Get Authorization Token

async OktoClient.getAuthorizationToken() retrieves the current authorization token for the authenticated user.

Parameters

This method doesn't take any parameters.

Response

Success Response

Field NameTypeDescription
resultPromise<string>Returns the authorization token

The authorization token is a JWT that can be used to authenticate requests to Okto services. This token is automatically managed by the SDK for internal operations.

Note

For error handling: