Unity: Oauth2 authentication not working for private data

1015
5
Jump to solution
06-14-2022 01:05 PM
coryeicher
Occasional Contributor

Hello,

I have some Scene Layers in ArcGIS Online that are shared only within my organization. I would like to view these in a Unity Scene. I followed the steps here without any success: https://developers.arcgis.com/unity/authentication/

Regardless of what I enter, I never see this: "the log in window will open in the default web browser window". As a result, my private data do not display in Unity.

I _am_ however able to view my private data in Unity if I use the AGS developer "Temporary Token" as my Unity API Key. I am also able to view my public AGOL data in Unity.

What further tips are out there for setting up Oauth2 to work to display private web scenes in Unity? 

Is the redirect Url important, or does it only need to match (what I configure in Unity === what I have in AGS developer)?

Is the client secret used at all? The doc does not mention using it.

Thanks,

-Cory

 

CORY EICHER
www.eichcorp.com
cory@eichcorp.com
Tags (4)
0 Kudos
1 Solution

Accepted Solutions
Matt_Nelson
Esri Contributor

Hi Cory,

Yes the deep link approach is the correct solution. Have you attempted it yet?

View solution in original post

0 Kudos
5 Replies
coryeicher
Occasional Contributor

Checking in.

Does anyone have oAuth2 working with this SDK?

Having set up oAuth2 for play mode, I can see these 2 breakpoints in OAuthChallengeHandlersInitializer.cs being hit... however neither method in SampleDesktopOAuthAuthenticationChallengeHandler.cs are ever hit.

coryeicher_0-1655738365050.png

And again, my browser isn't ever opening to ask for credentials, and my private data are not displaying (using oauth2).

Any ideas?

Thanks,

-Cory

CORY EICHER
www.eichcorp.com
cory@eichcorp.com
0 Kudos
Matt_Nelson
Esri Contributor

Have you setup the application on your arcgis online account with valid redirect URIs?

0 Kudos
coryeicher
Occasional Contributor

Hi Matt,

Returned to this today.

Thank you for the pointer in the right direction. I now have authentication working, but only in the Unity editor and simulator. This works using an http localhost url (e.g. http://localhost:3000)...

... However I've so far been unable to get ArcGIS auth working on the Oculus goggles. Following steps here, and trying an https url I see this (expected) error in the logs...

16:04:20.617 11913 12324 E Unity : One or more errors occurred. (Invalid redirect URI)
16:04:20.617 11913 12324 E Unity : Esri.ArcGISMapsSDK.Samples.Security.<>c__DisplayClass1_0:<HandleChallenge>b__0(Task`1)

... This is expected since the Esri sample code rejects both http and https urls. Then, to break it really good... I tried a simple string (guid), but that fails: it does not create a valid URI in the sample code...

... doing more research, it looks like this could work by implementing a deep link for my Oculus app, and then using that url for the Esri redirect URI. Can anyone confirm that this is the approach? Is there a simpler approach out there?

I realize this is veering away from an Esri Unity question, but much appreciated if someone has sorted this.

Thanks,

-Cory

CORY EICHER
www.eichcorp.com
cory@eichcorp.com
0 Kudos
Matt_Nelson
Esri Contributor

Hi Cory,

Yes the deep link approach is the correct solution. Have you attempted it yet?

0 Kudos
coryeicher
Occasional Contributor

Hi Matt Thank you. Auth ended up being deprioritized, so I have not yet attempted.

CORY EICHER
www.eichcorp.com
cory@eichcorp.com