I'm confused on what i put in this box.
This was more of a headache than it needed to be for me so I totally get it. However, it is pretty simple once you get it down.
Number one thing to remember: testing Steam in Unreal does not work in-editor. You need to either launch in Standalone mode or by right-clicking the .uproject file in your project folder and selecting "Launch Game" (that second one is the one I tend to use).
With that in mind here's the actual UE work/code time:
First, you need to ensure the OnlineSubsystemSteam plugin is enabled. I also disabled the other ones (aside from OnlineSubsystemNull) but I don't know if that's fully necessary.
Next, in your Project.Build.cs file you need to include a few dependency modules. I'll put the configuration I use since it works for me:
* "Steamworks" in PublicDependencyModules
* "OnlineSubsystemSteam" as a DynamicallyLoadedModule
* "OnlineSubsystem" as a PrivateDependencyModule
PublicDependencyModuleNames.Add("Steamworks"); PrivateDependencyModuleNames.Add("OnlineSubsystem"); DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
(Obviously you can throw these into the AddRange calls, too, but this works as an example.
This'll ensure UE hooks into the Steamworks SDK in it (if you are using a regular engine installation there's probably one already in there but you could modify it and upgrade from whatever version is built-in)
Second, you need to be able to call IOnlineIdentity::GetAuthToken(). As far as I know this isn't blueprint-exposed by default so you do need to do it yourself. Luckily it's all just fluff, nothing complicated here. I just put this in my project's UBlueprintFunctionLibrary. Here's an example:
.h file:
UFUNCTION(BlueprintCallable, BlueprintPure, Category="ExampleProject|OnlineSubsystem", meta=(DisplayName="GetAuthToken")) static FString BP_GetAuthToken(int32 LocalUserNum = 0);
As usual, UBlueprintFunctionLibraries need to be public.
.cpp file:
FString UExampleProjectBlueprintFunctionLibrary::BP_GetAuthToken(int LocalUserNum) { IOnlineSubsystem* OSS = IOnlineSubsystem::Get(STEAM_SUBSYSTEM); if (OSS) { return OSS->GetIdentityInterface()->GetAuthToken(LocalUserNum); } UE_LOG(LogTemp, Warning, TEXT("UExampleProjectBlueprintFunctionLibrary::BP_GetAuthToken couldn't find the Steam OSS!")); return FString(0); }
This example also lets you specify an ID for which local user on the game instance to get the info for but to my understanding you don't ever have to set it to anything other than 0 unless you have splitscreen which I know nothing of.
Third is the easiest part. All you need to do is call that function in Blueprints or C++ and it'll return a string to pass into FLoginWithSteamRequest.SteamTicket. Once you send that into the API call for LoginWithSteam with whatever other parameters you want you're all set!
Whoops. I just read over it and I messed up the .cpp file example. The parameter there is an int but it should be int32.
I just tried this and I'm getting an error "Invalid Input Parameters". My setup might be a bit different. Seems like here the idea is to use steam for pretty much everything and playfab just for server hosting, in my case I want to use playfabs online subsystem instead of steams but use steam as a means of registering or logging into the game. I have my custom app ID but I haven't publish my game since its nowhere near ready content wise. I was trying to test logging in with steam and connecting to a playfab server but I cannot get the steam authentication to work. I get constant "SteamAPI initialize failed: Condition not met" & "Steam Utils failed" warnings. Not sure what I'm missing. I'm wondering if I could just say screw steam authentication but still publish the game to the steam platform and just make my players sign up for a playfab account..
the .cpp does not work
,The .cpp file does not seem to work
4 People are following this question.