How to configure OnlineSubsystem LoginFlow

This is only necessary for desktop platforms. iOS and Android have their own implementations with their respective SDKs.

Desktop needs to use an integrated web browser to deliver user interaction. Including the “LoginFlow” module in the game build.cs is necessary as I’m sure you’ve discovered.

For the desktop, there is only a small bit of code to add. It is all contained below. The delegate will fire and hand the game a slate widget. You can slot that widget inside native Slate code, or wrap it in a UNativeNativeWidgetHost and pass it into your blueprint code if you choose.

  // Initialize the login flow UI code
  UWorld* World = GetWorld();
  FName FacebookIdentifier = Online::GetUtils()->GetOnlineIdentifier(World, FACEBOOK_SUBSYSTEM);
  FName GoogleIdentifier = Online::GetUtils()->GetOnlineIdentifier(World, GOOGLE_SUBSYSTEM);
  ILoginFlowModule& LoginFlowModule = ILoginFlowModule::Get();
  LoginFlowManager = LoginFlowModule.CreateLoginFlowManager();
  if (!LoginFlowManager->AddLoginFlow(FacebookIdentifier, ILoginFlowManager::FOnDisplayPopup::CreateUObject(this, &ThisClass::OnDisplayLoginWidget)))
  {
            UE_LOG(LogWExp, Warning, TEXT("No Facebook subsystem configured. It will be unavailable"));
  }
  if (!LoginFlowManager->AddLoginFlow(GoogleIdentifier, ILoginFlowManager::FOnDisplayPopup::CreateUObject(this, &ThisClass::OnDisplayLoginWidget)))
  {
        	UE_LOG(LogWExp, Warning, TEXT("No Google subsystem configured. It will be unavailable"));
  }
    
  MyGameClass::FOnPopupDismissed MyGameClass::OnDisplayLoginWidget(const TSharedRef<SWidget>& DisplayWidget)
  {
        // create a login flow UI which contains the slate widget or native host widget blueprint implementable
            ...
       //return a FOnPopupDismissed delegate that the underlying system will call when the screen is closed for any reason.
  }
    
  void MyGameClass::OnDismissLoginWidget()
  {
        // Widget dismissed by login flow or possibly game related Blueprint code
        // For slate typically
        Overlay->RemoveSlot(LoginFlow.ToSharedRef());
  }
        
  FReply MyGameClass::CancelLoginFlow()
  {
      // Blueprint callable if outer UI has way to shutdown login flow
      if (LoginFlowManager.IsValid())
       {
        	LoginFlowManager->CancelLoginFlow();
        }
        return FReply::Handled();
   }