Select to view content in your preferred language

Get a Runtime license UWP - Standard or higher through user authorization

613
4
Jump to solution
03-06-2025 07:12 AM
Labels (1)
Azamat
by
Emerging Contributor

Dears community,

I have a task to get a Runtime (UWP) license with authorization by logging into the portal to get license Standard or higher from user.

and I noticed that the old version of ArcGIS Runtime UWP 100... does not work in the new edition of version 200.6.0

Old version 100, it works

CredentialRequestInfo loginInfo = new CredentialRequestInfo();
loginInfo.ServiceUri = new Uri("https://arcgis.com/sharing/rest");
try
{
var cred = await AuthenticationManager.Current.GenerateCredentialAsync(
new Uri("https://arcgis.com/sharing/rest"),
"user",
"password") as ArcGISTokenCredential;

// Connect to the portal (ArcGIS Online or ArcGIS Portal) using the credential
ArcGISPortal arcgisPortal = await ArcGISPortal.CreateAsync(loginInfo.ServiceUri, cred);
// Get LicenseInfo from the portal
LicenseInfo licenseInfo = await arcgisPortal.GetLicenseInfoAsync();
ArcGISRuntimeEnvironment.SetLicense(licenseInfo);

 

But it doesn't work in 200 version ArcGIS Runtime UWP, unfortunately I couldn't get the code to work on the new version of the platform. I'm starting to think about using the old version 100 for work.
I'll be glad to get answers on where to go and what to look for.

 

Thank you for your support.

Best regards, Azamat

0 Kudos
1 Solution

Accepted Solutions
MatveiStefarov
Esri Contributor

The overload of CreateAsync that takes a specific credential has indeed been deprecated and removed.  In general, instead of passing/setting a specific Credential on your portal or layer, you should just add it to the AuthenticationManager.  Here is how you can accomplish your portal login in 200.x:

var cred = await AccessTokenCredential.CreateAsync(
                new Uri("https://arcgis.com/sharing/rest"),
                "user",
                "password");
AuthenticationManager.Current.AddCredential(cred);
ArcGISPortal arcgisPortal = await ArcGISPortal.CreateAsync(cred.ServerContext, loginRequired: true);
// the rest is unchanged

View solution in original post

4 Replies
dotMorten_esri
Esri Notable Contributor

This should continue to work. Can you clarify what you mean by "doesn't work" ?

0 Kudos
Azamat
by
Emerging Contributor

@dotMorten_esri ,

I mean that the project does not compile. Please look at the screenshot of the code with the warning that prevents compilation:

Azamat_1-1741316229434.png

I tried to change it but it didn't work 😞

Thank you.

Best regards, Azamat

 

 

0 Kudos
MatveiStefarov
Esri Contributor

The overload of CreateAsync that takes a specific credential has indeed been deprecated and removed.  In general, instead of passing/setting a specific Credential on your portal or layer, you should just add it to the AuthenticationManager.  Here is how you can accomplish your portal login in 200.x:

var cred = await AccessTokenCredential.CreateAsync(
                new Uri("https://arcgis.com/sharing/rest"),
                "user",
                "password");
AuthenticationManager.Current.AddCredential(cred);
ArcGISPortal arcgisPortal = await ArcGISPortal.CreateAsync(cred.ServerContext, loginRequired: true);
// the rest is unchanged
Azamat
by
Emerging Contributor

@MatveiStefarov , thank you very much, I'll be know.

Finally, it works.

Best regards, Azamat

0 Kudos