Simple Setup & Usage
This is the simplest approach, and for most projects which just need to gate some content behind subscription to a specific tier you probably won't need to get more complicated than this.
You will need your Client ID. The Client Secret can also be used, but is optional.
Your Redirect URI in your registered client should start with http://localhost
The process will work like this:
- You open the Patreon login and consent page for your user (either using their default web browser or the UMG Web Browser widget).
- While they are signing in and granting your application access to their data, we start up an HTTP server.
- By default the server will listen for a request at
http://localhost:8080/login, but you can customize this as you see fit. - Whatever you configure the server to use, you need to ensure that your application's configuration on the Patreon side has a matching
Redirect URI, e.g. if you setCallback Routeto/patreonandCallback Portto9999, you must update the settings in Patreon to include aRedirect URIofhttp://localhost:9999/patreon.
The
Callback RouteMUST start with"/"and be longer than just"/"but can otherwise be anything you want.The
Callback PortMUST be a positive integer, and unless you plan to use port80should be larger than1024 - By default the server will listen for a request at
- After consenting to sharing their data with your application, Patreon will make a request to the built-in HTTP server with a one-time use code we use to obtain an
Access Tokenon behalf of the user. - Once we have an access token, we use this to request the user's account information, including any tiers and benefits they are entitled to.
- You can then use this information as you want, e.g. checking if they are pledged to a specific tier and unlocking some content for them.
That sounds like a lot, but steps 1-3 are encapsulated inside of a single function which can be chained to a second function to handle step 4 for you, leaving only the actual logic for your application in step 5 up to you to implement.
Blueprint

C++
#include "Actions/PerformAuthenticationAsyncAction.h"
#include "Actions/GetPatreonUserInfoAsyncAction.h"
#include "APITokenInfo.h"
#define CLIENT_ID TEXT("<Your Client ID>")
#define CLIENT_SECRET TEXT("<Your Client Secret>") // optional
void MyClass::DoPatreonLogin() {
// create an authentication action expecting a callback at http://localhost:8080/login
UPerformAuthenticationAsyncAction* authAction = UPerformAuthenticationAsyncAction::PerformAuthenticationAsyncAction(
this, // world context
CLIENT_ID,
CLIENT_SECRET // can be set to an empty string
// callback route defaults to "/login"
// callback port defaults to 8080
);
// register callbacks for results
authAction->OnComplete.AddDynamic(this, &MyClass::OnAuthenticationComplete);
authAction->OnFail.AddDynamic(this, &MyClass::OnAuthenticationFailed);
// kick off action
authAction->Activate();
}
void MyClass::OnAuthenticationComplete(FAPITokenInfo TokenInfo) {
// now that we have a token, we can use it to fetch information about the user who just logged in
UGetPatreonUserInfoAsyncAction* getInfoAction = UGetPatreonUserInfoAsyncAction::GetPatreonUserInfoAsyncAction(
this, // world context
TokenInfo
);
getInfoAction->OnComplete.AddDynamic(this, &MyClass::OnGetUserInfoComplete);
getInfoAction->OnFail.AddDynamic(this, &MyClass::OnGetUserInfoFail);
getInfoAction->Activate();
}
void MyClass::OnAuthenticationFailed() {
UE_LOG(LogTemp, Error,
TEXT("Patreon authentication failed: The user may have denied the request for their data")
);
}
void MyClass::OnGetUserInfoComplete(FPatreonUserInfo UserInfo) {
// now that we have the user's information,
// we can check if they have pledged to a tier with unlockable content
if (UserInfo.HasTier("Special Tier")) {
UnlockSecretConent();
} else {
// suggest the user should pledge to the Special Tier ;)
}
}
void MyClass::OnGetUserInfoFail() {
UE_LOG(LogTemp, Error,
TEXT("Fetching user info from Patreon API failed: Was the access token invalid?")
);
}
For any questions, help, suggestions or feature requests, please feel free to contact me at nbpsup@gmail.com