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.

../../_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

Note

Because your ArdkAuthConfig is saved in your project with your API key, you should avoid sharing your ArdkAuthConfig publicly. For example, if you want to share your project in a public github repo, you should either remove your ArdkAuthConfig or clear out the Api Key field before sharing.

  1. To ensure your app is using the correct key, restart Unity.

Verifying Your Setup

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.

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)