# Xamarin Android custom error description from rule is hidden

**URL:** <https://community.auth0.com/t/xamarin-android-custom-error-description-from-rule-is-hidden/9397>\
**Category:** Get Help\
**Tags:** android, oidc, xamarin\
**Created:** [February 4, 2018, 11:08pm UTC](https://community.auth0.com/t/xamarin-android-custom-error-description-from-rule-is-hidden/9397 "2018-02-04T23:08:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pistoolirapu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pistoolirapu/32/13081_2.png) [@Pistoolirapu](https://community.auth0.com/u/Pistoolirapu)\
**Post date:** [February 4, 2018, 11:08pm UTC](https://community.auth0.com/t/xamarin-android-custom-error-description-from-rule-is-hidden/9397/1 "2018-02-04T23:08:30Z")

</div>

It is hard to understand how it is meant to sort out the custom error message from rules while creating app with Xamarin for Android.

Here is example of rule to be used to return custom error message:

```
function (user, context, callback) {
    var whitelist = 'example.com', 'example.org']; //authorized domains
    var userHasAccess = whitelist.some(
      function (domain) {
        var emailSplit = user.email.split('@');
        return emailSplit[emailSplit.length - 1].toLowerCase() === domain;
      });

    if (!userHasAccess) {
      return callback(new UnauthorizedError('This is custom error message. Please contact to something@something.com to get further help.'));
    }

    return callback(null, user, context);
} 

```

Now, when this rule is executed via Xamarin Android app:

> **[Add Login to Your .NET Android and iOS Application - Auth0 Docs](https://auth0.com/docs/quickstart/native/net-android-ios/interactive)**
>
> This tutorial demonstrates how to add user login with Auth0 to a .NET Android or iOS application.

This is the code which handles the return/result:

```
protected override async void OnNewIntent(Intent intent)
{
	base.OnNewIntent(intent);

	var loginResult = await client.ProcessResponseAsync(intent.DataString, authorizeState);

	var sb = new StringBuilder();
	if (loginResult.IsError)
	{
		sb.AppendLine($"An error occurred during login: {loginResult.Error}");
	}
	else
	{
		sb.AppendLine($"ID Token: {loginResult.IdentityToken}");
		sb.AppendLine($"Access Token: {loginResult.AccessToken}");
		sb.AppendLine($"Refresh Token: {loginResult.RefreshToken}");

		sb.AppendLine();

		sb.AppendLine("-- Claims --");
		foreach (var claim in loginResult.User.Claims)
		{
			sb.AppendLine($"{claim.Type} = {claim.Value}");
		}
	}

	userDetailsTextView.Text = sb.ToString();
}

```

Now the custom error message (‘This is custom error message. Please contact to [something@something.com](mailto:something@something.com) to get further help.’) is inside the query of intent.DataString.

Like this:

```
com.auth0.quickstart://xxx.eu.auth0.com/android/com.auth0.quickstart/callback?error=unauthorized&error_description=This is custom error message. Please contact to something@something.com to get further help.&state=xyz#

```

However, the loginResult does not offer this information as easy readable property.

Is this really how it should be? Would be nice to offer the same information directly to the user of app. Or is this error\_description more likely to be used in lock screen rather than user app? If that is the purpose, then this error\_description is got by splitting intent.DataString sufficient way, correct?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ricardo.batista](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ricardo.batista/32/7711_2.png) [@ricardo.batista](https://community.auth0.com/u/ricardo.batista)\
**Post date:** [February 10, 2018, 12:47am UTC](https://community.auth0.com/t/xamarin-android-custom-error-description-from-rule-is-hidden/9397/2 "2018-02-10T00:47:12Z")

</div>

The Xamarin Android uses the [Auth0 OIDC Client](https://auth0.github.io/auth0-oidc-client-net/documentation/intro.html) which in turn is based on the [IdentityModel OpenID Connect Client Library](https://github.com/IdentityModel/IdentityModel.OidcClient2). The `LoginResult` object that you get from the `ProcessResponseAsync` method is defined in this IdentityModel and, as you can see [here](https://github.com/IdentityModel/IdentityModel.OidcClient2/blob/82b1c5cd2670b5c7a41cfbb2586abb030a16db98/src/IdentityModel.OidcClient/Results/LoginResult.cs#L28) it only provides a simple error string. For this reason it was chosen to provide the error type (access\_denied, unauthorized) and not the full description in that field. The workaround, as you’ve figured out by yourself, is to parse the `intent.DataString` to get the error description.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 24, 2018, 2:04pm UTC](https://community.auth0.com/t/xamarin-android-custom-error-description-from-rule-is-hidden/9397/3 "2018-03-24T14:04:28Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
