> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PFAuthenticationGetEntityWithSecretKeyAsync

> Exchanges a title SecretKey for an Entity Token, or refreshes a still-valid Entity Token used by PlayFab server-side integrations for API calls.

Method to exchange a legacy AuthenticationTicket or title SecretKey for an Entity Token or to refresh a still valid Entity Token.

## Syntax

```cpp theme={null}
HRESULT PFAuthenticationGetEntityWithSecretKeyAsync(  
    PFServiceConfigHandle serviceConfigHandle,  
    const char* secretKey,  
    const PFAuthenticationGetEntityRequest* request,  
    XAsyncBlock* async  
)  
```

### Parameters

**`serviceConfigHandle`**   PFServiceConfigHandle

PFServiceConfigHandle returned from PFServiceConfigCreateHandle call.

**`secretKey`**   char\*<br />*In\_z*

Title Secret Key used to authenticate the service request.

**`request`**   [PFAuthenticationGetEntityRequest\*](/services/playfab/api-references/c/pfauthenticationtypes/structs/pfauthenticationgetentityrequest)

Populated request object.

**`async`**   XAsyncBlock\*<br />*Inout*

XAsyncBlock for the async operation.

### Return value

Type: HRESULT

Result code for this API operation.

## Remarks

This API is available on Win32, Linux, and macOS. This API must be called with X-SecretKey, X-Authentication or X-EntityToken headers. An optional EntityKey may be included to attempt to set the resulting EntityToken to a specific entity, however the entity must be a relation of the caller, such as the master\_player\_account of a character. If sending X-EntityToken the account will be marked as freshly logged in and will issue a new token. If using X-Authentication or X-EntityToken the header must still be valid and cannot be expired or revoked. When the asynchronous task is complete, call [PFAuthenticationGetEntityWithSecretKeyGetResult](/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationgetentitywithsecretkeygetresult) to get the result.

## Requirements

**Header:** PFAuthentication.h

## See also

[PFAuthentication members](/services/playfab/api-references/c/pfauthentication/pfauthentication_members)


## Related topics

- [PFAuthenticationGetEntityWithSecretKeyGetResult](/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationgetentitywithsecretkeygetresult.md)
- [Entity Handles](/services/playfab/sdks/c/entity-handles.md)
- [PFSegmentsServerGetAllSegmentsAsync](/services/playfab/api-references/c/pfsegments/functions/pfsegmentsservergetallsegmentsasync.md)
- [PFTitleDataManagementServerGetTimeAsync](/services/playfab/api-references/c/pftitledatamanagement/functions/pftitledatamanagementservergettimeasync.md)
- [Game servers from title entity](/services/playfab/sdks/c/server.md)
