Unable to Generate Credentials for ArcGIS Online

2890
2
06-21-2016 09:48 PM
DavidMcCorkindale1
New Contributor III

Hi,

I'm try to use token based authentication to get to my organisation portal on ArcGIS online using the ESRI ArcGISRuntime for .NET.

When trying to run the below code I get the following error.

Any help would be appreciated.

Code:

string uri = @"https://qgsp.maps.arcgis.com/sharing/rest";

"Starting credentials.");

var credentials = await IdentityManager.Current.GenerateCredentialAsync(uri, username, password) as ArcGISTokenCredential;

Error:

Unhandled Exception: System.AggregateException: One or more errors occurred. ---
> System.Net.Http.HttpRequestException: An error occurred while sending the requ
est. ---> System.Net.WebException: Unable to connect to the remote server ---> S
ystem.Net.Sockets.SocketException: A connection attempt failed because the conne
cted party did not properly respond after a period of time, or established conne
ction failed because connected host has failed to respond 50.17.189.113:443
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Sock
et s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state,
IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, Tr
ansportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar
)
   --- End of inner exception stack trace ---
   at Esri.ArcGISRuntime.Http.ArcGISHttpClientHandler.ArcGISClientHandlerInterna
l.<SendAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Esri.ArcGISRuntime.Security.ArcGISTokenWebRequest.<RequestTokenAsync>d__1.
MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Esri.ArcGISRuntime.Security.ArcGISTokenCredential.<GetArcGISTokenAsync>d__
d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Esri.ArcGISRuntime.Security.ArcGISTokenCredential.<GenerateTokenImplAsync>
d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Esri.ArcGISRuntime.Security.TokenCredential.<GenerateTokenAsync>d__d.MoveN
ext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at DownloadSurvey.Program.<Login>d__3.MoveNext() in C:\Users\mccorkdm\documen
ts\visual studio 2015\Projects\DownloadSurvey\DownloadSurvey\Program.cs:line 39
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceled
Exceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotifica
tion)
   at System.Threading.Tasks.Task`1.get_Result()
   at DownloadSurvey.Program.Main(String[] args) in C:\Users\mccorkdm\documents\
visual studio 2015\Projects\DownloadSurvey\DownloadSurvey\Program.cs:line 22

0 Kudos
2 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi

Can you add a simple app which shows the exact code you have (excluding your credentials obviously)?

We can try running against a Token secured Portal to ascertain what the problem might be.

Cheers

Mike

DavidMcCorkindale1
New Contributor III

Hi Mike,

I've attached my app code to the original question.  You'll note that the app.config is configured to use a web proxy.  I'm not sure if this is having some of the effect.

Thanks.

David

0 Kudos