====== Phone ====== This method is used to easily allow users to authenticate with AcceleratXR via their registered phone number. It does not require a password be stored on the account. For that it is considered a password-less authentication method. This method also has the benefit of bypassing any configured multi-factor authentication settings with the account, since it effectively uses a time-based one-time password to function internally. A user submits an authentication request to the ``/auth/phone/`` endpoint. The system then sends a text message to the phone number (assuming it's registered) with a time-based one-time password code embedded in the body of the message. The following example shows the initial request to receive the totp code via phone. .. tabs:: .. tab:: C++ .. code-block:: cpp CoreSDK->LoginPhone(_XPLATSTR("phone")).then([](pplx::task task) { try { // Force the exception to be re-thrown if an error occurred. task.get(); } catch (const axr::sdk::Exception& e) { // Handle error here } }); .. tab:: C# .. code-block:: csharp try { await CoreSDK.LoginPhone("phone"); } catch (Exception error) { // Handle error here } .. tab:: TypeScript .. code-block:: typescript try { await CoreSDK.loginPhone("phone"); } catch (error: any) { // Handle error here } .. tab:: Unity .. code-block:: csharp try { AXRCoreSDK SDK = AXRCoreSDK.GetInstance(); await SDK.Instance.LoginPhone("phone"); } catch (Exception error) { Debug.LogError("Failed phone login. Error=" + error.Message); } .. tab:: Unreal .. code-block:: cpp const IOnlineSubsystem* OnlineSub = Online::GetSubsystem(GetWorld()); check(OnlineSub != nullptr); const IOnlineIdentityPtr IdentityInterface = OnlineSub->GetIdentityInterface(); check(IdentityInterface.IsValid()); FDelegateHandle LoginDelegateHandler; auto LoginDelegate = FOnLoginCompleteDelegate::CreateLambda([=](int32 InLocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error) { if (Error.Len() > 0) { // Handle error here } IdentityInterface->ClearOnLoginCompleteDelegate_Handle(InLocalUserNum, LoginDelegateHandler); }); LoginDelegateHandler = IdentityInterface->AddOnLoginCompleteDelegate_Handle(0, LoginDelegate); FOnlineAccountCredentials creds; creds.Type = ELoginMethods::ToString(ELoginMethods::Phone); creds.Id = TEXT("username"); IdentityInterface->Login(0, creds); .. tab:: REST API .. code-block:: HTTP GET /auth/phone/ HTTP/1.1 Once the code is received the user then submits the provided code to the backend to retrieve the final access token. .. tabs:: .. tab:: C++ .. code-block:: cpp CoreSDK->LoginPhone(_XPLATSTR("phone"), _XPLATSTR("code")).then([](pplx::task task) { try { // Force the exception to be re-thrown if an error occurred. task.get(); } catch (const axr::sdk::Exception& e) { // Handle error here } }); .. tab:: C# .. code-block:: csharp try { await CoreSDK.LoginPhone("phone", "code"); } catch (Exception error) { // Handle error here } .. tab:: TypeScript .. code-block:: typescript try { await CoreSDK.loginPhone("phone", "code"); } catch (error: any) { // Handle error here } .. tab:: Unity .. code-block:: csharp try { AXRCoreSDK SDK = AXRCoreSDK.GetInstance(); await SDK.Instance.LoginPhone("phone", "code"); } catch (Exception error) { Debug.LogError("Failed phone login. Error=" + error.Message); } .. tab:: Unreal .. code-block:: cpp const IOnlineSubsystem* OnlineSub = Online::GetSubsystem(GetWorld()); check(OnlineSub != nullptr); const IOnlineIdentityPtr IdentityInterface = OnlineSub->GetIdentityInterface(); check(IdentityInterface.IsValid()); FDelegateHandle LoginDelegateHandler; auto LoginDelegate = FOnLoginCompleteDelegate::CreateLambda([=](int32 InLocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error) { if (Error.Len() > 0) { // Handle error here } IdentityInterface->ClearOnLoginCompleteDelegate_Handle(InLocalUserNum, LoginDelegateHandler); }); LoginDelegateHandler = IdentityInterface->AddOnLoginCompleteDelegate_Handle(0, LoginDelegate); FOnlineAccountCredentials creds; creds.Type = ELoginMethods::ToString(ELoginMethods::Phone); creds.Id = TEXT("username"); creds.Token = TEXT("code"); IdentityInterface->Login(0, creds); .. tab:: REST API .. code-block:: HTTP POST /auth/phone/ HTTP/1.1 Content-Type: application/json Content-Length: ... { "code": }