Authentication using browser
Last updated
Last updated
Let's see how to make work an authentication in our Unreal Engine Plugin.
We'll be using the following blueprints:
Output values:
Return Value: { "url": string, "connectionToken": string }
Input values:
ConnectionToken: string
- a connection token that is received after the Get Connection URL request.
Output values:
Return Value: { "address": string }
Download JSON plugin for UE - https://www.unrealengine.com/marketplace/en-US/product/json-blueprint
You can create this blueprint by following this:
You can create this blueprint by following this:
You can create this blueprint by following this:
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.
In the 'Delay' blueprint set a delay in 1.0 sec. Add a 'Get Authentication' blueprint and connect the 'Delay' and this blueprint.
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.
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.
Add a 'Branch' blueprint and connect it with the 'Get Authentication' blueprint and the '==' blueprint.
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.
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.
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)