I started a small exercise and had some features published via Arcmap as feature services, using the URL I was able to display those features on a base map on mobile devices, I wanted to kick this exercise up a notch, so I created a map on arcgis portal, and added those features as layers using the same account. Now I want to display the contents of that portal for the specific user, So again I had the user enter their credentials, so I can access their portal content, but I am getting an exception every time that I cannot figure out why
"Esri.ArcGISRuntime.Http.ArcGISWebException: You do not have permissions to access this resource or perform this operation. at Esri.ArcGISRuntime.Http.ArcGISHttpClientHandler+ArcGISClientHandlerInternal.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00e0a] in <46d786262d8c49d5b1ed57411302734a>:0 at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) "
Also take a look at the code at the bottom, and let me know if I am missing something, the logic is I get the username and password, I create the Credential object, and set the ChallengeHandler. Then I use the URL of the portal to access the Portal object and set its Credential,also I use the PortalUser to access the user and get their content. what am I doing wrong to get the exception above ?
Here is a chunk of the code
public async void LoginButtonClicked(){
_tokenCredential = loginPageFrm.NetworkCred;
var handler = new ChallengeHandler(CreateCredentialAsync);
AuthenticationManager.Current.ChallengeHandler = handler;
var arcgisPortal = await ArcGISPortal.CreateAsync(uriPortal);
arcgisPortal.Credential = _tokenCredential;
var loginType =await ArcGISPortal.GetLoginTypeForUriAsync(uriPortal);
var portUSer=await PortalUser.CreateAsync(arcgisPortal, loginPage.UserName);
var contents= await portUSer.GetContentAsync();
}
private async Task<Credential>CreateCredentialAsync(CredentialRequestInfo info){
if (_loginTaskCompletionSource != null) { return null; }
_loginTaskCompletionSource = new TaskCompletionSource<Credential>(info);
try
{
_loginTaskCompletionSource.TrySetResult(_tokenCredential);
return await _loginTaskCompletionSource.Task;
}
catch (Exception ex)
{
_loginTaskCompletionSource = null;
Log.LogException(Ex,True);
}
return null;
}