Authentication

How to set up a project with your an authentication token.

Creating the ArdkAuthConfig

In order to use the networking and awareness features of ARDK, an authentication token must be fetched from the ARDK servers.

The following steps need to be repeated for each project that uses ARDK.

  1. Create a Resources/ARDK directory inside your project’s Assets directory and add an ArdkAuthConfig asset to it. Do not change its default name.

Note

If you’ve imported the ARDK-Examples package into your Unity project, delete the empty ArdkAuthConfig asset that already exists in the Assets/ARDKExamples/Resources/ARDK folder as well. If your project has multiple ArdkAuthConfigs, ARDK will print the following warning to the Unity Console window: “There are multiple ArdkAuthConfigs in Resources/ARDK/ directories, loading the first API key found. Remove extra ArdkAuthConfigs to prevent API key problems”.

../../_images/ardk_auth_config.png
  1. Fill the Api Key field in the ArdkAuthConfig.asset with any API key generated through your Lightship.dev account.

../../_images/api_key.png
  1. To ensure your app is using the correct key, restart Unity.

Verifying Your Setup

To verify that your API key is valid and set up properly, try out the LowLevelNetworking scene in the ARDK-Examples Unity project.

  1. Find the NetworkSessionManager component, located on the ExampleManager object in the scene hierarchy.

../../_images/network_session_manager.png
  1. Set the NetworkSessionManager’s RuntimeEnvironment property to LiveDevice.

../../_images/runtime_environment_live.png
  1. Enter Play Mode.

  2. Click the Init button and then the Connect button in the Game View window.

  • If authentication succeeds, the connection to ARDK servers will succeed as well and you will see the log message: “Connected as Host”

  • If authentication fails, you will see a “Connection Failed” log error message with an error code of 700 (your API key is invalid) or 701 (your API key isn’t properly set in your ArdkAuthConfig)

Note

Verification of authentication in the Unity Editor currently only works on Intel Macs. If using a different development platform, you must deploy your ARDK app to a mobile device in order to verify that authentication has been set up properly. Logs can be viewed by clicking the Toggle Log button.