Login User
This function helps your user to trigger the login process. The login flow will be triggered based on the selected provider.
Parameters
UWeb3AuthSDK::GetInstance()->Login()
requires FWeb3AuthLoginParams
as a required input.
FWeb3AuthLoginParams
- Table
- Interface
Parameter | Description |
---|---|
loginProvider | It sets the OAuth login method to be used. You can use any of the supported values are GOOGLE , FACEBOOK , REDDIT , DISCORD , TWITCH , APPLE , LINE , GITHUB , KAKAO , LINKEDIN , TWITTER , WEIBO , WECHAT , EMAIL_PASSWORDLESS . |
extraLoginOptions? | It can be used to set the OAuth login options for corresponding loginProvider . For instance, you'll need to pass user's email address as. Default value for the field is null , and it accepts FExtraLoginOptions as a value. |
redirectUrl? | Url where user will be redirected after successfull login. By default user will be redirected to same page where login will be initiated. Default value for the field is null , and accepts FString as a value. |
appState? | It can be used to keep track of the app state when user will be redirected to app after login. Default is null , and accepts FString as a value. |
mfaLevel? | Customize the MFA screen shown to the user during OAuth authentication. Default value for field is MFALevel.DEFAULT , which shows MFA screen every 3rd login. It accepts FMFALevel as a value. |
dappShare? | Custom verifier logins can get a dapp share returned to them post successful login. This is useful if the dapps want to use this share to allow users to login seamlessly. It accepts FString as a value. |
curve? | It will be used to determine the public key encoded in the jwt token which returned in getUserInfo function after user login. The default value is FCurve::speck256k1 . |
USTRUCT(BlueprintType)
struct FLoginParams
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString loginProvider;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString dappShare;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FExtraLoginOptions extraLoginOptions;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString appState;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString redirectUrl;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FMFALevel mfaLevel;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FCurve curve;
FLoginParams() {};
};
Provider
UENUM(BlueprintType)
enum class EWeb3AuthProvider : uint8
{
GOOGLE UMETA(DisplayName = "Google"),
FACEBOOK UMETA(DisplayName = "Facebook"),
REDDIT UMETA(DisplayName = "Reddit"),
DISCORD UMETA(DisplayName = "Discord"),
TWITCH UMETA(DisplayName = "Twitch"),
APPLE UMETA(DisplayName = "Apple"),
LINE UMETA(DisplayName = "Line"),
GITHUB UMETA(DisplayName = "GitHub"),
KAKAO UMETA(DisplayName = "Kakao"),
LINKEDIN UMETA(DisplayName = "LinkedIn"),
TWITTER UMETA(DisplayName = "Twitter"),
WEIBO UMETA(DisplayName = "Weibo"),
WECHAT UMETA(DisplayName = "WeChat"),
EMAIL_PASSWORDLESS UMETA(DisplayName = "Email Passwordless"),
JWT UMETA(DisplayName = "JWT")
};
Usage
void AYourGameMode::LoginWithGoogle()
{
FWeb3AuthLoginParams LoginParams;
LoginParams.LoginProvider = TEXT("google");
UWeb3AuthSDK::GetInstance()->Login(LoginParams);
}
UFUNCTION()
void AYourGameMode::OnWeb3AuthLoginSuccess(const FString& PrivateKey, const FString& PublicAddress)
{
UE_LOG(LogTemp, Warning, TEXT("Web3Auth Login Success - Private Key: %s"), *PrivateKey);
UE_LOG(LogTemp, Warning, TEXT("Web3Auth Login Success - Address: %s"), *PublicAddress);
}