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

# PFAuthenticationGetEntityWithSecretKeyAsync

> Get an Entity Token by passing a PFServiceConfigHandle and a title Secret Key. On success, it issues a new entity token and emits a PlayStream event.

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\*\
*In\_z*

Title Secret Key used to authenticate the service request.

**`request`**   [PFAuthenticationGetEntityRequest\*](https://docs.xbox.com/services/playfab/api-references/c/pfauthenticationtypes/structs/pfauthenticationgetentityrequest.md)

Populated request object.

**`async`**   XAsyncBlock\*\
*Inout*

XAsyncBlock for the async operation.

### Return value

Type: HRESULT

Result code for this API operation.

## Remarks

This API is available on Windows, Linux, and macOS. This API must be called with X-SecretKey, X-Authentication or X-EntityToken headers. The header must still be valid and cannot be expired or revoked.If successful, it will issue a new entity token and emit the 'entity\_logged\_in' PlayStream event. When the asynchronous task is complete, call [PFAuthenticationGetEntityWithSecretKeyGetResult](https://docs.xbox.com/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationgetentitywithsecretkeygetresult.md) to get the result.

## Requirements

**Header:** PFAuthentication.h

## See also

[PFAuthentication members](https://docs.xbox.com/services/playfab/api-references/c/pfauthentication/pfauthentication_members.md)


## Related topics

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