--- title: "Log out" slug: "dsm-example-code-log-out" updated: 2024-12-10T18:03:14Z published: 2024-12-10T18:03:14Z canonical: "support.fortanix.com/dsm-example-code-log-out" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.fortanix.com/llms.txt > Use this file to discover all available pages before exploring further. # Log out Bearer tokens are valid for a limited period of time. User bearer tokens will expire after 24 hours of inactivity, and application bearer tokens will expire after 10 minutes of inactivity. An application may terminate its session to immediately invalidate its bearer token. > [!TIP] > TIP > > It is a good idea to do this before an application exits to limit the possibility of a stolen bearer token being used to access the Fortanix DSM server. **C++** - [C++](/docs/dsm-example-code-log-out#tabs-1) - [C#](/docs/dsm-example-code-log-out#tabs-2) - [Go](/docs/dsm-example-code-log-out#tabs-3) - [Java](/docs/dsm-example-code-log-out#tabs-4) - [Python](/docs/dsm-example-code-log-out#tabs-5) - [PHP](/docs/dsm-example-code-log-out#tabs-6) - [Javascript](/docs/dsm-example-code-log-out#tabs-7) - [REST API using curl](/docs/dsm-example-code-log-out#tabs-8) ```bash CK_RV logout(CK_FUNCTION_LIST_PTR p11, CK_SESSION_HANDLE hSession) { return p11->C_Logout(hSession); } ``` ### C# ```bash AuthenticationApi authenticationApi = new AuthenticationApi(); AuthResponse response = authenticationApi.Terminate(); ``` ### Go ```bash client := sdkms.Client{          Endpoint: "",          HTTPClient: http.DefaultClient, } ctx := context.Background() _, err := client. AuthenticateWithAPIKey(ctx, ) client.TerminateSession(ctx) ``` ### Java ```bash AuthenticationApi authenticationApi = new AuthenticationApi(apiClient); authenticationApi.terminate(); ``` ### Python ```bash api_instance = sdkms.v1.AuthenticationApi(api_client=client) api_instance.terminate() ``` ### PHP ```bash public function logout() {    $authenticationApi = new Swagger\Client\Api\AuthenticationApi($client);    $authInstance->terminate(); } ``` ### Javascript ```bash var logoutCallback = function(error, data, response) {    if (error) {        console.error("Error: " + JSON.stringify(response));    } else {        console.log('logout successfully');    } }; var authenticationApi = new FortanixSdkmsRestApi.AuthenticationApi() authenticationApi.terminate(logoutCallback); ``` ### REST API using curl ```bash curl /sys/v1/session/terminate -H 'Authorization: Bearer YhXwwa- 6C...L9kRxswmPZkEFQ2ig5g' ``` Fortanix Data Security Manager (DSM) is the world’s first cloud service secured with Intel® SGX. With Fortanix DSM, you can securely generate, store, and use cryptographic keys and certificates, as well as other secrets such as passwords, API keys, tokens, or any blob of data. Your business-critical applications and containers can integrate with Fortanix DSM using legacy cryptographic interfaces (PKCS#11, CNG, and JCE) or using the native Fortanix DSM RESTful interface. ## Related - [Decryption](/dsm-example-code-decryption.md)