google-ar / arcore-unity-extensions

Google ARCore Extensions and Geospatial Creator for Unity's AR Foundation
Other
351 stars 98 forks source link

Missing apikey error in keyless authentication #42

Open GiacomoRavaioli opened 3 years ago

GiacomoRavaioli commented 3 years ago

Trying to host a persistent Google Cloud Anchor with the keyless android authentication strategy (case below) or resolving an existing persistent Google Cloud Anchor, both with a new project targeting Android and the ARCore Persistent Cloud Anchor Sample (case below), produces the following error:

2021-05-12 16:06:35.592 8297-10346/? E/ARCore-AnchorServiceClient: Error calling CreateAnchor RPC: gsk: PERMISSION_DENIED: The request is missing a valid API key. at gsi.i(PG:1) at hfu.c(PG:3) at guk.a(PG:3) at gvd.run(PG:2) at hcd.run(PG:2) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) 2021-05-12 16:06:35.592 8297-10346/? W/native: hotspot_anchor_hoster_v1beta2.cc:164 Error during hosting: PERMISSION_DENIED: The request is missing a valid API key. 2021-05-12 16:06:35.610 8297-8323/? I/Unity: Failed to host the Cloud Anchor with error ErrorNotAuthorized. Google.XR.ARCoreExtensions.Samples.PersistentCloudAnchors.ARViewManager:UpdatePendingCloudAnchors() Google.XR.ARCoreExtensions.Samples.PersistentCloudAnchors.ARViewManager:Update()<

Am I missing some steps to make it work?

Tests with the Api Key android authentication strategy worked using an API key generated on the GCP Console.

The Firebase app has been correctly registered on the Firebase Project Console and its SHA-1 has been set. On the GCP Console, under APIs and Services -> Credentials, a new entry on the OAuth 2.0 Client IDs has been automatically generated for the newly registered app in the Firebase Project Console. When the app starts, firebase is initialized correctly.

The behaviour doesn’t change whether the FirebaseAuth.unitypackage is present or not.

With the ARCore Android SDK and the same GCP and Firebase projects, everything works fine with keyless authentication.

Sotfware & Packages used:

usefulslug commented 3 years ago

I'm having the same problem. I have tried a variety of gradle versions as a comment on an old similar issue mentioned it, but no dice. Keyless anchor creation fails with CloudAnchorState.ErrorNotAuthorized despite the keystore signature being correctly set up in the GCP Console. Unity 2020.3.6f1 ARCore Extension 1.23.0 ARFoundation 4.1.7 ARCore XR Plugin 4.1.7

ghost commented 3 years ago

Has this problem been solved? Why is the Unity team not responding to this? If keyless authentication does not work in Unity3d, then they should mention this.

devbridie commented 3 years ago

I can't reproduce any problems with the keyless workflow in a totally clean environment using the Persistent Cloud Anchors sample app. Here are some troubleshooting steps; try them out and ensure that the values in your Google Cloud project match:

  1. Check the SHA-1 key used to sign your apk and ensure it's the same as the key in GCP: Android/sdk/build-tools/30.0.1/apksigner verify --print-certs built-unity-game.apk
  2. Use aapt to confirm the package name of your built apk and ensure it's the same as the package name in GCP: Android/sdk/build-tools/30.0.1/aapt dump badging built-unity-game.apk | grep package: