Email#
This method is used to easily allow users to authenticate with AcceleratXR via their registered e-mail address. 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/email/<email> endpoint. The system then sends a message
to the e-mail provided (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 e-mail:
1CoreSDK->LoginEmail(_XPLATSTR("email")).then([](pplx::task<void> task)
2{
3 try
4 {
5 // Force the exception to be re-thrown if an error occurred.
6 task.get();
7 }
8 catch (const xbe::sdk::Exception& e)
9 {
10 // Handle error here
11 }
12});
1try
2{
3 await CoreSDK.LoginEmail("email");
4}
5catch (Exception error)
6{
7 // Handle error here
8}
1try
2{
3 await CoreSDK.loginEmail("email");
4}
5catch (error: any)
6{
7 // Handle error here
8}
1try
2{
3 AXRCoreSDK SDK = AXRCoreSDK.GetInstance();
4 await SDK.Instance.LoginEmail("email");
5}
6catch (Exception error)
7{
8 Debug.LogError($"Failed e-mail login. Error={error.Message}");
9}
1FOnlineSubsystemXBE* OSS = (FOnlineSubsystemXBE*)(IOnlineSubsystem::Get(XBE_SUBSYSTEM));
2check(OnlineSub != nullptr);
3const IOnlineIdentityPtr IdentityInterface = OnlineSub->GetIdentityInterface();
4check(IdentityInterface.IsValid());
5
6FDelegateHandle LoginDelegateHandler;
7auto LoginDelegate = FOnLoginCompleteDelegate::CreateLambda([=](
8 int32 InLocalUserNum,
9 bool bWasSuccessful,
10 const FUniqueNetId& UserId,
11 const FString& Error)
12{
13 if (Error.Len() > 0)
14 {
15 // Handle error here
16 }
17
18 IdentityInterface->ClearOnLoginCompleteDelegate_Handle(
19 InLocalUserNum, LoginDelegateHandler);
20});
21LoginDelegateHandler = IdentityInterface->AddOnLoginCompleteDelegate_Handle(
22 0, LoginDelegate);
23
24FOnlineAccountCredentials creds;
25creds.Type = ELoginMethods::ToString(ELoginMethods::Email);
26creds.Id = TEXT("username");
27
28IdentityInterface->Login(0, creds);
GET /auth/email/{email} HTTP/1.1
Once the code is received the user then submits the provided code to the backend to retrieve the final access token:
1CoreSDK->LoginEmail(_XPLATSTR("email"), _XPLATSTR("code"))
2 .then([](pplx::task<void> task)
3{
4 try
5 {
6 // Force the exception to be re-thrown if an error occurred.
7 task.get();
8 }
9 catch (const xbe::sdk::Exception& e)
10 {
11 // Handle error here
12 }
13});
1try
2{
3 await CoreSDK.LoginEmail("email", "code");
4}
5catch (Exception error)
6{
7 // Handle error here
8}
1try
2{
3 await CoreSDK.loginEmail("email", "code");
4}
5catch (error: any)
6{
7 // Handle error here
8}
1try
2{
3 AXRCoreSDK SDK = AXRCoreSDK.GetInstance();
4 await SDK.Instance.LoginEmail("email", "code");
5}
6catch (Exception error)
7{
8 Debug.LogError($"Failed e-mail login. Error={error.Message}");
9}
1FOnlineSubsystemXBE* OSS = (FOnlineSubsystemXBE*)(IOnlineSubsystem::Get(XBE_SUBSYSTEM));
2check(OnlineSub != nullptr);
3const IOnlineIdentityPtr IdentityInterface = OnlineSub->GetIdentityInterface();
4check(IdentityInterface.IsValid());
5
6FDelegateHandle LoginDelegateHandler;
7auto LoginDelegate = FOnLoginCompleteDelegate::CreateLambda([=](
8 int32 InLocalUserNum,
9 bool bWasSuccessful,
10 const FUniqueNetId& UserId,
11 const FString& Error)
12{
13 if (Error.Len() > 0)
14 {
15 // Handle error here
16 }
17
18 IdentityInterface->ClearOnLoginCompleteDelegate_Handle(
19 InLocalUserNum, LoginDelegateHandler);
20});
21LoginDelegateHandler = IdentityInterface->AddOnLoginCompleteDelegate_Handle(
22 0, LoginDelegate);
23
24FOnlineAccountCredentials creds;
25creds.Type = ELoginMethods::ToString(ELoginMethods::Email);
26creds.Id = TEXT("username");
27creds.Token = TEXT("code");
28
29IdentityInterface->Login(0, creds);
1POST /auth/email/{email} HTTP/1.1
2Content-Type: application/json
3Content-Length: ...
4
5{
6 "code": "{TOTP}"
7}