I3DHAuthHandler.h Source File

I3DHAuthHandler.h Source File#

instant3Dhub: I3DHAuthHandler.h Source File
instant3Dhub
I3DHAuthHandler.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "GameFramework/Actor.h"
9
10#include "I3DHAuthHandler.generated.h"
11
13USTRUCT(BlueprintType)
14struct FI3DHAuthError
15{
16 GENERATED_BODY()
17
18 FI3DHAuthError()
19 {
20 }
21
22 FI3DHAuthError(const FString& UserMessage)
24 {
25 }
26
28 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
30};
31
33DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FI3DHAuthSuccessDelegate, FString, AccessToken, bool, WasRefresh);
35DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FI3DHAuthFailureDelegate, const FI3DHAuthError&, Error, bool, WasRefresh);
36
37struct FI3DHTokenResponse;
38class FI3DHAuthServer;
39class IHttpRequest;
40
49UCLASS(ClassGroup = "instant3Dhub")
50class INSTANT3DHUB_API AI3DHAuthHandler : public AActor
51{
52 friend class FI3DHAuthServer;
53
54 GENERATED_BODY()
55
56 AI3DHAuthHandler();
57
58public:
59 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
60
61public:
62 // Core API:
63
73 UFUNCTION(BlueprintCallable, Category = "{instant3DhubAuth}")
74 void Init(const FString& ClientId, const FString& Scope, const FString& AuthorizationUrl, const FString& TokenUrl);
75
82 UFUNCTION(BlueprintCallable, Category = "{instant3DhubAuth}")
83 void Start();
84
90 UFUNCTION(BlueprintCallable, Category = "{instant3DhubAuth}")
91 void Reset();
92
93private:
95 void RefreshTimerCallback();
96 void HandleTokenResponse(const FI3DHTokenResponse* TokenResponse, bool WasRefresh);
97
99
100 // Note on thread safety: All variables are intended to be accessed from the
101 // game thread only. Access from other threads will require additional
102 // synchronization.
103
104private:
105 // Basic OAuth 2.0 configuration:
106
107 FString ClientId;
108 FString Scope;
109 FString AuthorizationUrl;
110 FString TokenUrl;
111
112public:
119
121 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
123
125 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
127
129 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
131
133 UPROPERTY(BlueprintReadWrite, Category = "{instant3DhubAuth}")
135
137
138public:
150
152 UPROPERTY(BlueprintAssignable, Category = "{instant3DhubAuth}")
154
156 UPROPERTY(BlueprintAssignable, Category = "{instant3DhubAuth}")
158
160
161private:
162 // Internal state:
163
164 TSharedPtr<FI3DHAuthServer> Server;
165 TSharedPtr<IHttpRequest> TokenRequest;
166
167 FString RefreshToken;
168 FTimerHandle RefreshTimer;
169};
DECLARE_DYNAMIC_MULTICAST_DELEGATE void FI3DHAuthFailureDelegate(const FI3DHAuthError &Error, bool WasRefresh)
AuthFailure Delegate Type.
DECLARE_DYNAMIC_MULTICAST_DELEGATE void FI3DHAuthSuccessDelegate(FString AccessToken, bool WasRefresh)
AuthSuccess Delegate Type.
@ Error
Indicates a general error that doesn't match any of the specific ones.
Definition I3DHDataTypes.h:1346
FString ErrorHtmlResponse
The error HTML response.
Definition I3DHAuthHandler.h:134
FString SuccessRedirectUrl
URL of the success redirect.
Definition I3DHAuthHandler.h:122
void Start()
Start the login process.
void Reset()
Cancel active login process, if one exists, and delete any obtained login information.
FI3DHAuthSuccessDelegate Succeeded
Delegate invoked if the login process was successful.
Definition I3DHAuthHandler.h:153
void Init(const FString &ClientId, const FString &Scope, const FString &AuthorizationUrl, const FString &TokenUrl)
Configure the handler with required parameters.
FString ErrorRedirectUrl
URL of the error redirect.
Definition I3DHAuthHandler.h:130
FI3DHAuthFailureDelegate Failed
Delegate invoked if the login process has failed.
Definition I3DHAuthHandler.h:157
FString SuccessHtmlResponse
The success HTML response.
Definition I3DHAuthHandler.h:126
Authentication Error with a UserMessage.
Definition I3DHAuthHandler.h:15
FString UserMessage
Error message suitable for display to the end user.
Definition I3DHAuthHandler.h:29