Authentication using browser

Let's see how to make work an authentication in our Unreal Engine Plugin.

We'll be using the following blueprints:

Get Connection Url

Output values:

  • Return Value: { "url": string, "connectionToken": string }

Get Authentication

Input values:

  • ConnectionToken: string - a connection token that is received after the Get Connection URL request.

Output values:

  • Return Value: { "address": string }

JSON plugin

Download JSON plugin for UE - https://www.unrealengine.com/marketplace/en-US/product/json-blueprint

ToJson

You can create this blueprint by following this:

ToValue

You can create this blueprint by following this:

Value - ToJsonObject

You can create this blueprint by following this:

Making blueprints

  1. Add a 'Get Connection URL' blueprint and make a return value connect to a 'ToJson' blueprint, add a 'Delay' blueprint and connect the first blueprint to the 'Delay' blueprint.

  2. In the 'Delay' blueprint set a delay in 1.0 sec. Add a 'Get Authentication' blueprint and connect the 'Delay' and this blueprint.

  3. Add a 'ToValue' blueprint with 'url' as an argument and connect it with the first 'ToJson' blueprint. Add a 'Value - ToJsonObject' blueprint and connect it with the 'ToValue' blueprint and the 'Get Authentication' blueprint.

  4. Add a new 'ToJson' blueprint, connect it with the 'Get Authentication' blueprint. Add a 'ToValue' blueprint with 'address' as an argument and connect it with the 'ToJson' blueprint. Add a 'Value - ToJsonObject' blueprint and connect it with the 'ToValue' blueprint. Add a '==' blueprint and connect it with the 'Value - ToJsonObject' blueprint.

  5. Add a 'Branch' blueprint and connect it with the 'Get Authentication' blueprint and the '==' blueprint.

  6. In the 'Branch' blueprint on the 'true' statement add and connect a new 'Delay' blueprint with 2.0 sec duration and connect the 'Delay' blueprint to the 'Get Authentication' blueprint.

  7. In the 'Branch' blueprint on the 'false' statement add and connect a 'Print String' blueprint that will show that your auth is successful. You have to change this blueprint to your custom blueprint that will handle the successful auth.

In the result you should get this scheme. Use the scheme to make your blueprints right.

After hitting the Play Button the plugin will start working and it'll redirects your user to https://tryangle-simple.web.app/?connectionToken=yourConnectionToken, where 'yourConnectionToken' is a connection token stored in TryAngle that is received when plugin is working.

Connecting wallet and signing an auth message

A user will be prompted to connect MetaMask wallet and sign a message that will ensure that this user is exactly registered under his/her wallet.

Signing messages is a secure way to authenticate for users and providers (https://docs.metamask.io/guide/signing-data.html#signing-data-with-metamask)

Last updated