RedirectPort
RedirectPort
#Overview
name: RedirectPort
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of RedirectPort is to specify the port number used in the redirect URL for Google authentication in the OnlineSubsystemGoogle plugin of Unreal Engine 5. This setting is crucial for the proper configuration of the Google authentication process within the online identity system.
The OnlineSubsystemGoogle plugin, specifically the online identity module, relies on this setting variable. It is used in the FOnlineIdentityGoogle class, which is responsible for handling Google authentication in Unreal Engine projects.
The value of this variable is typically set in the DefaultEngine.ini configuration file under the [OnlineSubsystemGoogle.OnlineIdentityGoogle] section. If not specified, the code attempts to read it from this configuration file.
RedirectPort interacts with other variables such as LoginRedirectUrl and ClientId to form a complete configuration for Google authentication. These variables work together to create a valid authentication setup.
Developers must be aware that:
- This port number should be available and not blocked by firewalls.
- It should match the port number specified in the Google Developer Console for the application.
- The default value is 9000, but it can be changed as needed.
Best practices when using this variable include:
- Always specify it in the DefaultEngine.ini file to avoid relying on default values.
- Ensure it matches the configuration in the Google Developer Console.
- Choose a port number that is not commonly used by other services to avoid conflicts.
- Verify that the chosen port is open and accessible in the deployment environment.
- Use the same port consistently across development and production environments to avoid confusion.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEngine.ini:2277, section: [OnlineSubsystemGoogle.OnlineIdentityGoogle]
- INI Section:
OnlineSubsystemGoogle.OnlineIdentityGoogle
- Raw value:
9001
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemGoogle/Source/Private/Rest/OnlineIdentityGoogleRest.cpp:19
Scope (from outer to inner):
file
function FOnlineIdentityGoogle::FOnlineIdentityGoogle
Source code excerpt:
UE_LOG_ONLINE_IDENTITY(Warning, TEXT("Missing LoginRedirectUrl= in [OnlineSubsystemGoogle.OnlineIdentityGoogle] of DefaultEngine.ini"));
}
if (!GConfig->GetInt(TEXT("OnlineSubsystemGoogle.OnlineIdentityGoogle"), TEXT("RedirectPort"), LoginURLDetails.RedirectPort, GEngineIni))
{
UE_LOG_ONLINE_IDENTITY(Warning, TEXT("Missing RedirectPort= in [OnlineSubsystemGoogle.OnlineIdentityGoogle] of DefaultEngine.ini"));
}
GConfig->GetArray(TEXT("OnlineSubsystemGoogle.OnlineIdentityGoogle"), TEXT("LoginDomains"), LoginDomains, GEngineIni);
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemGoogle/Source/Private/Rest/OnlineIdentityGoogleRest.cpp:55
Scope (from outer to inner):
file
function bool FOnlineIdentityGoogle::Login
Source code excerpt:
{
ErrorStr = FString::Printf(TEXT("OnlineSubsystemGoogle is improperly configured in DefaultEngine.ini LoginRedirectUrl=%s RedirectPort=%d ClientId=%s"),
*LoginURLDetails.LoginRedirectUrl, LoginURLDetails.RedirectPort, *LoginURLDetails.ClientId);
}
else
{
if (LocalUserNum < 0 || LocalUserNum >= MAX_LOCAL_PLAYERS)
{
ErrorStr = FString::Printf(TEXT("Invalid LocalUserNum=%d"), LocalUserNum);
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemGoogle/Source/Private/Rest/OnlineIdentityGoogleRest.h:57
Scope: file
Source code excerpt:
FString LoginRedirectUrl;
/** Port to append to the LoginRedirectURL when communicating with Google auth services */
int32 RedirectPort = 9000;
/** The client id given to us by Google */
FString ClientId;
/** Config based list of permission scopes to use when logging in */
TArray<FString> ScopeFields;
/** A value used to verify our response came from our server */
FString State;
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemGoogle/Source/Private/Rest/OnlineIdentityGoogleRest.h:70
Scope (from outer to inner):
file
function bool IsValid
Source code excerpt:
{
// LoginUrl skipped because its filled in by discovery service
return !LoginRedirectUrl.IsEmpty() && !ClientId.IsEmpty() && (RedirectPort > 0) && (ScopeFields.Num() > 0);
}
FString GenerateNonce()
{
// random number to represent client generated state for verification on login
State = FString::FromInt(FMath::Rand() % 100000);
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemGoogle/Source/Private/Rest/OnlineIdentityGoogleRest.h:83
Scope (from outer to inner):
file
function FString GetRedirectURL
Source code excerpt:
{
//const FString Redirect = TEXT("urn:ietf:wg:oauth:2.0:oob:auto");
return FString::Printf(TEXT("%s:%d"), *LoginRedirectUrl, RedirectPort);
}
FString GetURL() const
{
FString Scopes = FString::Join(ScopeFields, TEXT(" "));