Authentication

How to retrieve an authentication token.

Steps

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 requires access to ARDK's networking features. This includes running networked sessions in the Unity Editor.

1) Create a Resources/ARDK directory inside your project's Assets directory and add an ArdkAuthConfig asset to it. Do not change it's default name. If you are importing the ARDKExamples project, an empty ArdkAuthConfig is already provided in the ARDKExamples/Resources/ARDK/ directory.

ArdkAuthConfig

2) Fill the Api Key field in the ArdkAuthConfig.asset with any Api key generated through your Niantic.dev account.

ApiKey

3) ARDK will automatically attempt to load the Api Key upon application startup. If you are attempting to use networking features from the Unity Editor directly after completing step 2 and the API key is failing to load, try restarting the Unity Editor.

Note
If you've imported the ARDK-Examples package into your Unity project, you may have an extra ArdkAuthConfig asset under Assets/ARDKExamples/Resources/ARDK. Unity will generate the following warning if this extra asset exists in your project: "There are multiple ArdkAuthConfigs in Resources/ARDK/ directories, loading the first API key found. Remove extra ArdkAuthConfigs to prevent API key problems". Delete this asset and ensure that the ArdkAuthConfig you created is the only ArdkAuthConfig in your project.

4) Any ServerConfiguration that is created will now be configured to connect to the AR backend servers with the specified API key. To verify that your API key works, try out the LowLevelNetworking scene in the ARDK-Examples Unity project.

On the ExampleManager object in the scene hierarchy there is a NetworkSessionManager component. Set its RuntimeEnvironment property to LiveDevice, start play mode, and click the Init then Connect buttons. If the connection to the ARDK servers is successful, you should see the following screen:

Connected