# 类 UAuthenticationBlueprintApi

> Reference the Blueprint Application Programming Interface for authentication operations.

##### 声明##declaration

```cpp
UCLASS()
class UAuthenticationBlueprintApi : public UBlueprintFunctionLibrary
```

## 委托##delegates

### FAuthenticationResponseDelegate##fauthenticationresponsedelegate

#### 声明##declaration

```cpp
DECLARE_DYNAMIC_DELEGATE_OneParam(FAuthenticationResponseDelegate, FAuthenticationResponse, Response)
```

#### 返回类型##return-type

[FAuthenticationResponse](./models/authentication-response.md)

### FAuthenticationStateChangedResponseDelegate##fauthenticationstatechangedresponsedelegate

#### 声明##declaration

```cpp
DECLARE_DYNAMIC_DELEGATE_OneParam(FAuthenticationStateChangedResponseDelegate, FAuthenticationStateChangedResponse, Response)
```

#### 返回类型##return-type

[FAuthenticationStateChangedResponse](./models/authentication-state-changed-response.md)

### FAuthenticationGetUserDelegate##fauthenticationgetuserdelegate

#### 声明##declaration

```cpp
DECLARE_DYNAMIC_DELEGATE_OneParam(FAuthenticationGetUserDelegate, FAuthenticationUserResponse, Response)
```

#### 返回类型##return-type

[FAuthenticationUserResponse](./models/authentication-user-response.md)

### FAuthenticationDeleteUserDelegate##fauthenticationdeleteuserdelegate

#### 声明##declaration

```cpp
DECLARE_DYNAMIC_DELEGATE_OneParam(FAuthenticationDeleteUserDelegate, bool, bResponse)
```

#### 返回类型##return-type

布尔值

### FAuthenticationPlayerProfileChangedResponseDelegate##fauthenticationplayerprofilechangedresponsedelegate

#### 声明##declaration

```cpp
DECLARE_DYNAMIC_DELEGATE_OneParam(FAuthenticationPlayerProfileChangedResponseDelegate, FAuthenticationPlayerProfileChangedResponse, Response)
```

#### 返回类型##return-type

[FAuthenticationPlayerProfileChangedResponse](./models/authentication-player-profile-changed-response.md)

### FAuthenticationPlayerProfileDeletedResponseDelegate##fauthenticationplayerprofiledeletedresponsedelegate

#### 声明##declaration

```cpp
DECLARE_DYNAMIC_DELEGATE_OneParam(FAuthenticationPlayerProfileDeletedResponseDelegate, FAuthenticationPlayerProfileDeletedResponse, Response)
```

#### 返回类型##return-type

[FAuthenticationPlayerProfileDeletedResponse](./models/authentication-player-profile-deleted-response.md)

## 方法##methods

### Sign In Anonymously##sign-in-anonymously

匿名登录当前用户。不需要任何凭据，并且会话仅限于当前设备。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
static void SignInAnonymously(FAuthenticationSignInOptions Options, FAuthenticationResponseDelegate ResponseDelegate)
```

#### 参数##parameters

| **Name**                | **类型**                                                                                               | **描述**              |
| :---------------------- | :--------------------------------------------------------------------------------------------------- | :------------------ |
| 期权 (Options)            | [FAuthenticationSignInOptions](./models/authentication-sign-in-options.md)                           | 登录选项。               |
| Response Delegate（响应委托） | [FAuthenticationResponseDelegate](./authentication-blueprint-api.md#fauthenticationresponsedelegate) | 当 API 返回一个响应时执行的委托。 |

### Get User Info##get-user-info

返回当前玩家的玩家信息，例如帐户创建时间和关联的外部 ID。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
void GetUserInfo(FAuthenticationGetUserDelegate ResponseDelegate) const
```

#### 参数##parameter

| **Name**                | **类型**                                                                                             | **描述**              |
| :---------------------- | :------------------------------------------------------------------------------------------------- | :------------------ |
| Response Delegate（响应委托） | [FAuthenticationGetUserDelegate](./authentication-blueprint-api.md#fauthenticationgetuserdelegate) | 当 API 返回一个响应时执行的委托。 |

### Delete User##delete-user

永久删除当前登录的用户。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
static void DeleteUser(FAuthenticationDeleteUserDelegate ResponseDelegate)
```

#### 参数##parameter

| **Name**                | **类型**                                                                                                   | **描述**              |
| :---------------------- | :------------------------------------------------------------------------------------------------------- | :------------------ |
| Response Delegate（响应委托） | [FAuthenticationDeleteUserDelegate](./authentication-blueprint-api.md#fauthenticationdeleteuserdelegate) | 当 API 返回一个响应时执行的委托。 |

### Register State Changed Callback##register-state-changed-callback

挂接到在身份验证状态更改时执行的委托。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
static void RegisterStateChangedCallback(FAuthenticationStateChangedResponseDelegate ResponseDelegate)
```

#### 参数##parameter

| **Name**                | **类型**                                                                                                                       | **描述**           |
| :---------------------- | :--------------------------------------------------------------------------------------------------------------------------- | :--------------- |
| Response Delegate（响应委托） | [FAuthenticationStateChangedResponseDelegate](./authentication-blueprint-api.md#fauthenticationstatechangedresponsedelegate) | 在身份验证状态更改时执行的委托。 |

### Sign Out##sign-out

在提供的配置文件名称下注销当前用户。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
static bool SignOut(bool bClearCredentials = false)
```

#### 参数##parameter

| **Name**                | **类型** | **描述**              |
| :---------------------- | :----- | :------------------ |
| Clear Credentials（清除凭据） | 布尔值    | 清除用于登录同一帐户的会话令牌的选项。 |

### Switch Profile##switch-profile

将当前配置文件切换为新的配置文件名称。如果在该名称下未找到配置文件，则会创建新的配置文件。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
void SwitchProfile(FString ProfileName)
```

#### 参数##parameters

| **Name**             | **类型**                                                                                             | **描述**                       |
| :------------------- | :------------------------------------------------------------------------------------------------- | :--------------------------- |
| Profile Name（配置文件名称） | [字符串](https://docs.unrealengine.com/5.3/en-US/blueprint-variables-in-unreal-engine/#variabletypes) | 要切换到的配置文件的名称，如果尚不存在，则会添加该名称。 |

### Profile Exists##profile-exists

检查配置文件是否存在。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
bool ProfileExists(FString ProfileName) const
```

#### 参数##parameters

| **Name**             | **类型**                                                                                             | **描述**       |
| :------------------- | :------------------------------------------------------------------------------------------------- | :----------- |
| Profile Name（配置文件名称） | [字符串](https://docs.unrealengine.com/5.3/en-US/blueprint-variables-in-unreal-engine/#variabletypes) | 要检查的配置文件的名称。 |

### Get Current Profile Name##get-current-profile-name

返回当前配置文件的名称。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
FString GetCurrentProfileName() const
```

#### 返回##returns

| **类型**                                                                                             | **描述**     |
| :------------------------------------------------------------------------------------------------- | :--------- |
| [字符串](https://docs.unrealengine.com/5.3/en-US/blueprint-variables-in-unreal-engine/#variabletypes) | 当前配置文件的名称。 |

### Get Profile Names##get-profile-names

返回所有活跃玩家配置文件名称。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
TArray<FString> GetProfileNames() const
```

#### 返回##returns

| **类型**                                                                                               | **描述**        |
| :--------------------------------------------------------------------------------------------------- | :------------ |
| [字符串](https://docs.unrealengine.com/5.3/en-US/blueprint-variables-in-unreal-engine/#variabletypes)数组 | 所有活跃玩家配置文件名称。 |

### Register Profile Changed Callback##register-profile-changed-callback

挂接到在玩家配置文件更改时执行的处理程序。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
void RegisterProfileChangedCallback(FAuthenticationPlayerProfileChangedResponseDelegate ResponseDelegate)
```

#### 参数##parameters

| **Name**                | **类型**                                                                                                                                       | **描述**             |
| :---------------------- | :------------------------------------------------------------------------------------------------------------------------------------------- | :----------------- |
| Response Delegate（响应委托） | [FAuthenticationPlayerProfileChangedResponseDelegate](./authentication-blueprint-api.md#fauthenticationplayerprofilechangedresponsedelegate) | 在玩家配置文件更改时执行的处理程序。 |

### Register Profile Deleted Callback##register-profile-deleted-callback

挂接到在玩家配置文件被删除时执行的处理程序。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
void RegisterProfileDeletedCallback(FAuthenticationPlayerProfileDeletedResponseDelegate ResponseDelegate)
```

#### 参数##parameter

| **Name**                | **类型**                                                                                                                                       | **描述**              |
| :---------------------- | :------------------------------------------------------------------------------------------------------------------------------------------- | :------------------ |
| Response Delegate（响应委托） | [FAuthenticationPlayerProfileDeletedResponseDelegate](./authentication-blueprint-api.md#fauthenticationplayerprofiledeletedresponsedelegate) | 在玩家配置文件被删除时执行的处理程序。 |

### IsSignedIn##issignedin

检查用户是否已登录。

> **Note:**
>
> 用户可以保持登录但会话已到期。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
bool IsSignedIn() const
```

#### 返回##returns

| **类型** | **描述**                    |
| :----- | :------------------------ |
| bool   | 如果用户已登录，为 true，否则为 false。 |

### IsAnonymous##isanonymous

检查用户是否匿名登录。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
bool IsAnonymous() const
```

#### 返回##returns

| **类型** | **描述**                     |
| :----- | :------------------------- |
| bool   | 如果用户匿名登录，为 true，否则为 false。 |

### IsAuthorized##isauthorized

检查用户是否仍然被授权。

> **Note:**
>
> 只要用户的访问令牌仍然有效，用户就仍然被授权。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
bool IsAuthorized() const
```

#### 返回##returns

| **类型** | **描述**                    |
| :----- | :------------------------ |
| bool   | 如果用户被授权，为 true，否则为 false。 |

### IsExpired##isexpired

检查用户会话是否到期。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
bool IsExpired() const
```

#### 返回##returns

| **类型** | **描述**                      |
| :----- | :-------------------------- |
| bool   | 如果用户会话已到期，为 true，否则为 false。 |

### SessionTokenExists##sessiontokenexists

检查是否为当前配置文件存储了现有会话令牌。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
bool SessionTokenExists() const
```

#### 返回##returns

| **类型** | **描述**                      |
| :----- | :-------------------------- |
| bool   | 如果为当前配置文件存储了现有会话令牌，则为 true。 |

### GetUnityProjectId##getunityprojectid

返回 Unity Project ID。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
FGuid GetUnityProjectId() const
```

#### 返回##returns

| **类型**                                                                       | **描述**            |
| :--------------------------------------------------------------------------- | :---------------- |
| [Guid](https://docs.unrealengine.com/5.3/en-US/API/Runtime/Core/Misc/FGuid/) | Unity Project ID。 |

### GetUnityEnvironmentName##getunityenvironmentname

返回 Unity 环境名称。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
FString GetUnityEnvironmentName() const
```

#### 返回##returns

| **类型**                                                                                             | **描述**      |
| :------------------------------------------------------------------------------------------------- | :---------- |
| [字符串](https://docs.unrealengine.com/5.3/en-US/blueprint-variables-in-unreal-engine/#variabletypes) | Unity 环境名称。 |

### GetAccessToken##getaccesstoken

返回当前用户的访问令牌。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
FString GetAccessToken() const
```

#### 返回##returns

| **类型**                                                                                             | **描述**                           |
| :------------------------------------------------------------------------------------------------- | :------------------------------- |
| [字符串](https://docs.unrealengine.com/5.3/en-US/blueprint-variables-in-unreal-engine/#variabletypes) | 如果当前用户已登录，为当前用户的访问令牌字符串，否则为空字符串。 |

### GetSessionToken##getsessiontoken

返回当前用户的会话令牌。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
FString GetSessionToken() const
```

#### 返回##returns

| **类型**                                                                                             | **描述**                           |
| :------------------------------------------------------------------------------------------------- | :------------------------------- |
| [字符串](https://docs.unrealengine.com/5.3/en-US/blueprint-variables-in-unreal-engine/#variabletypes) | 如果当前用户已登录，为当前用户的会话令牌字符串，否则为空字符串。 |

### GetUserId##getuserid

当前登录用户的 ID。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
FString GetUserId() const
```

#### 返回##returns

| **类型**                                                                                             | **描述**                       |
| :------------------------------------------------------------------------------------------------- | :--------------------------- |
| [字符串](https://docs.unrealengine.com/5.3/en-US/blueprint-variables-in-unreal-engine/#variabletypes) | 如果当前用户已登录，为当前用户的 ID，否则为空字符串。 |

### GetState##getstate

Authentication 子系统的当前状态。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintPure, Category = "Unity Gaming Services | Authentication")
EAuthenticationStates GetState() const
```

#### 返回##returns

| **类型**                               | **描述**                   |
| :----------------------------------- | :----------------------- |
| [身份验证状态](./authentication-states.md) | Authentication 子系统的当前状态。 |

### GetState##getstate

设置 Unity Project ID。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
static void SetUnityProjectId(FGuid Value)
```

#### 参数##parameters

| **Name** | **类型**                                                                       | **描述**               |
| :------- | :--------------------------------------------------------------------------- | :------------------- |
| 值        | [Guid](https://docs.unrealengine.com/5.3/en-US/API/Runtime/Core/Misc/FGuid/) | 新的 Unity Project ID。 |

### SetUnityEnvironmentName##setunityenvironmentname

设置 Unity 环境名称。

#### 声明##declaration

```cpp
UFUNCTION(BlueprintCallable, Category = "Unity Gaming Services | Authentication")
static void SetUnityEnvironmentName(FString Value)
```

#### 参数##parameters

| **Name** | **类型**                                                                                             | **描述**          |
| :------- | :------------------------------------------------------------------------------------------------- | :-------------- |
| 值        | [字符串](https://docs.unrealengine.com/5.3/en-US/blueprint-variables-in-unreal-engine/#variabletypes) | 新的 Unity 环境 ID。 |
