Cannot Generate Identity Credentials for Portal

5077
6
Jump to solution
03-24-2016 12:04 PM
JoeHershman
MVP Regular Contributor

Hi,

I am trying to do something (that I think should be) very simple, connect to a Portal from a Runtime application.

However, when I run

TokenCredential credential = await IdentityManager.Current.GenerateCredentialAsync(portalUrl, "username", "password");

An exception is thrown, "The token service URL is not set."

This works fine if I am using a service url

TokenCredential credential = await IdentityManager.Current.GenerateCredentialAsync(serviceUrl, "username", "password");

What I am doing seems to me to be exactly how it is described here Access the ArcGIS platform—ArcGIS Runtime SDK for .NET | ArcGIS for Developers​.  But maybe I am missing something.  I also tried connecting to our AGOL account and get the same exception.

What am I missing?

Thanks

-Joe

Tags (1)
1 Solution

Accepted Solutions
JoeHershman
MVP Regular Contributor

After some help from Mike I was able to find the problem.

Another symptom of this issue was that Dashboard application would crash when I tried to connect to our Portal

In the end this was a configuration issue.  Because of how our domain is configured we use an internal DNS.  In setting up the public URL for the portal was included in the domain DNS.  For some reason even though I use the public URL when setting up Web Adapter for Portal some Portal configuration still points to the internal machine name.  This was causing a name conflict and is the source of the error I see.

I ended up removing the domain DNS mapping and then going through the setup on our DMZ machine.  This got everything to be correctly using only the public name.  After that I am able to connect using the API and Dashboard no longer crashes.  After that I was able to add the domain mapping back so the other machines only internal to the domain can access using the public URL

View solution in original post

0 Kudos
6 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

What Portal Uri are you using? (for example "https://arcgis.com/sharing/rest")

Cheers

Mike

0 Kudos
JoeHershman
MVP Regular Contributor

Hi,

I use something like, https://portal.mydomain.com/arcgis for our internal portal.  This is the same Url I would enter to access to portal in a browser.  For trying AGOL I use https://myorganization.maps.arcgis.com/.  This is what it seems the help is telling me

0 Kudos
JoeHershman
MVP Regular Contributor

Michael Branscomb​ would you have any ideas what changes I need to make to setup the credentials to Portal correctly?  Should I be using a rest api url and not the portal url?

Thanks

-Joe

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

We'll need to see some more code to properly determine what the problem might be, but have you tried using https://<PortalURl>/sharing/rest ?

Cheers

Mike

0 Kudos
JoeHershman
MVP Regular Contributor

Michael Branscomb

Basically the following line of code fails with: 

System.Net.WebException: Error: NameResolutionFailure  at System.Net.HttpWebRequest.EndGetRequestStream

var cred = await IdentityManager.Current.GenerateCredentialAsync(
  new Uri("https://portal.domain.com/arcgis/sharing/rest"),
  "username",
  "password") as ArcGISTokenCredential;

If I use AGOL then it works.  So this works

var cred = await IdentityManager.Current.GenerateCredentialAsync(
  new Uri("http://mycompany.maps.arcgis.com/sharing/rest"),
  "user",
  "password") as ArcGISTokenCredential;

I would be happy to give you the url and a login to our portal to test, I really need to get this working using a hosted Portal not AGOL

0 Kudos
JoeHershman
MVP Regular Contributor

After some help from Mike I was able to find the problem.

Another symptom of this issue was that Dashboard application would crash when I tried to connect to our Portal

In the end this was a configuration issue.  Because of how our domain is configured we use an internal DNS.  In setting up the public URL for the portal was included in the domain DNS.  For some reason even though I use the public URL when setting up Web Adapter for Portal some Portal configuration still points to the internal machine name.  This was causing a name conflict and is the source of the error I see.

I ended up removing the domain DNS mapping and then going through the setup on our DMZ machine.  This got everything to be correctly using only the public name.  After that I am able to connect using the API and Dashboard no longer crashes.  After that I was able to add the domain mapping back so the other machines only internal to the domain can access using the public URL

0 Kudos