Select to view content in your preferred language

PregeneratedTokenCredential is missing from SDK

333
3
04-19-2025 06:59 PM
ChrisAnderson7
Emerging Contributor

I am trying to use the new credential system included with Esri's Unity SDK version 2.0. I already have a system for obtaining the user's credentials so creating a handler the way the samples indicate won't work or it adds multiple logins required for my app to function (poor user experience). That was when i came across PregeneratedTokenCredential:

https://developers.arcgis.com/net/api-reference/api/ios/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Securi...

The problem is that this doesn't appear to be included in the GameEngine version and unless I'm missing something, I don't have a way of just using my own system and just provide the token to Esri's sdk to use as well.

0 Kudos
3 Replies
AShahbaz
Esri Contributor

With the new authentication implementation you shouldn't need to login multiple times (unless you are loading contents from multiple portals). By design, you will also be prompted to login (again) when you open the editor and/or press play. If you are having issues with multiple logins other than these cases, please let us know. 

If you want to keep using pregenerated tokens, you should be able to use them as the api key. If you want to load different layers with different tokens/keys, you would have to add those layers through api. 

Another option that you have is to implement your own login handler for the play mode and standalone builds based on our sample code in `SampleOAuthUserLoginPromptHandler` and insert the pregenerated code as the server response in there. To register the custom handler with the authentication manager, write your own script or modify the `SampleAuthenticationHandlerInitializer` component. 

0 Kudos
ChrisAnderson7
Emerging Contributor
Wait, so I can use the token I get from the Oauth2 process (I already have a login process in place for my app to connect to a user's portal) as the API key? That will solve all my issues all at once if that's the case. Please confirm. Thanks.

Please confirm if the following is a true statement. The API key value can be the access token received from a standard Oauth2 login workflow.
0 Kudos
AShahbaz
Esri Contributor

I did a test and was able to use a pregenerated access code (generated through the oauth workflow) for loading arcgis online/organization content. But I wasn't able to make it work for enterprise (portal) content. Is that the type of data you are using?
Could you also describe how you are generating the access code?

0 Kudos