Authentication with Discord
Starting from version 4.2.5, the Discord login method is fully supported by the plugin. This means that you can now authenticate your users using their Discord account.
Credits where it's due: The code majorly comes from the XistGG's Discord Game Sample (opens in a new tab) sample project.
Web Settings
Setting up Discord App
Before you can start using the Discord login method, you need to create a Discord application. To do this, follow these steps:
-
Click on the New Application button in the top right corner and fill in the Name and select the Team and click on the Create button.
- Click on the OAuth2 tab in the left sidebar and click on the Add Redirect button and add the redirect URL which for us at the moment is
http://127.0.0.1
.
- On the same page(or on the General Information tab), copy the Client ID. You will need this later.
That is all you need to do on the Discord Developer Portal. Now let's move on to Epic Devportal.
Setting up Epic Devportal
-
Go to the Epic Devportal (opens in a new tab).
-
Now select the product you want to add the Discord login method to and then go to it's Product Settings page.
-
Click on the Identity Providers tab and then click on the Add Identity Provider button.
-
Select Discord from the dropdown and then fill in the Client ID and a Description of your choice and click on the Save button.
- To attach the Identity Provider to your sandbox, go to Sandboxes and select the sandbox you want to attach the Identity Provider to. Now click on Identity Providers and select the profile you just created. Press Save and you are done!
This will take a few minutes to get it to populate, give it a few minutes and you are ready to go!
Unreal Settings
Configuring Config
In the DefaultGame.ini
file, you need to add the following lines:
[/Script/DiscordGame.DiscordGameSubsystem]
ClientId={Your Client ID}
Make sure to add the plugin to your project by adding it to your project's Plugin folder.
Minimal Hardwork
So, few things you need to do to get the Discord login method working in your project:
- Add the
Discord SDK Library
to your project. You can download the Discord v3.2.1 (opens in a new tab) from the Discord Developer Portal and after unzipping, copy the contents of the lib folder toPlugins\EOSIntegrationKit\Source\ThirdParty\DiscordGameSDK
like this:
- Unzip the
discord-cpp.zip
folder present in thePlugins\EOSIntegrationKit\Source\DiscordGame
folder.
Blueprint Implementation
Now the final step is to implement the Discord login method in your project. Here is an example of how you can do this:
That is it! You have successfully implemented the Discord login method in your Unreal Engine project. Now you can authenticate your users using their Discord account.