I have a C# and WPF application (ArcGIS Runtime 100.0) setup with ArcGIS Online log-in. I know it works, my credentials work fine. Digging around my orginization (I'm admin) I realized the other user accounts have "_" in their user names. On a hunch, I created a new account, ensuring the user name did not contain "_"...bingo. I can log into my portal from my application.
// Create a token credential using the provided username and password
ArcGISTokenCredential userCredentials = await AuthenticationManager.Current.GenerateCredentialAsync
(new Uri(requestInfo.ServiceUri.GetLeftPart(UriPartial.Path)),
_userName,
_password,
requestInfo.GenerateTokenOptions) as ArcGISTokenCredential;
_eventAggregator.GetEvent<ArcGISUserChangedEvent>().Publish(
new Image.Infrastructure.Events.Args.ArcGISUserChangedArgs { Token = userCredentials });
// Set the result on the task completion source
_loginTaskCompletionSource.TrySetResult(userCredentials);