protected void OnSuccess(Uri uri, TaskCompletionSource<OAuthResult> tcs)
		{
			string queryParams = uri.Query;
			string[] parts = queryParams.Split('&');
			Dictionary<string, string> queryMap = new Dictionary<string, string>();
			for (int i = 0; i < parts.Length; i++)
			{
				string[] kv = parts[i].Split('=');
				queryMap.Add(kv[0], kv[1]);
			}

			string result = null;
			queryMap.TryGetValue("result", out result);
			if ("success" == result)
			{
				string sessionToken = null;
				string authRes = null;
				queryMap.TryGetValue("fh_auth_session", out sessionToken);
				queryMap.TryGetValue("authResponse", out authRes);
				OAuthResult oauthResult = new OAuthResult(OAuthResult.ResultCode.OK, sessionToken, Uri.UnescapeDataString(authRes));
				tcs.TrySetResult(oauthResult);
			}
			else
			{
				string errorMessage = null;
				queryMap.TryGetValue("message", out errorMessage);
				OAuthResult oauthResult = new OAuthResult(OAuthResult.ResultCode.FAILED, new Exception(errorMessage));
				tcs.TrySetResult(oauthResult);
			}

		}
		public void OnFail(bool cancelled){
			OAuthResult oauthResult = new OAuthResult (OAuthResult.ResultCode.FAILED, new Exception ("NOT_FINISHED"));
			if (cancelled) {
				oauthResult = new OAuthResult (OAuthResult.ResultCode.CANCELLED, new Exception ("USER_CANCELLED"));
			}
			this.tcs.TrySetResult (oauthResult);
		}
			public override void OnReceive(Context context, Intent intent)
			{
				this.parent.logger.d (OAuthClientHandlerService.LOG_TAG, "recieved event, data: " + intent.GetStringExtra ("url"), null);
				string data = intent.GetStringExtra ("url");
				if ("NOT_FINISHED".Equals (data)) {
					OAuthResult oauthResult = new OAuthResult (OAuthResult.ResultCode.FAILED, new Exception ("NOT_FINISHED"));
					this.parent.tcs.TrySetResult (oauthResult);
				} else if ("CANCELLED".Equals (data)) {
					OAuthResult oauthResult = new OAuthResult (OAuthResult.ResultCode.CANCELLED, new Exception ("USER_CANCELLED"));
					this.parent.tcs.TrySetResult (oauthResult);
				} else {
					this.parent.appContext.UnregisterReceiver (this.parent.receiver);
					this.parent.OnSuccess (new Uri (data), this.parent.tcs);
				}
			}
 void backkey_Pressed(object sender, CancelEventArgs e)
 {
     Close();
     e.Cancel = true;
     OAuthResult authResult = new OAuthResult(OAuthResult.ResultCode.CANCELLED);
     tcs.SetResult(authResult);
 }
 void browser_NavigateFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e)
 {
     Close();
     OAuthResult result = new OAuthResult(OAuthResult.ResultCode.FAILED, e.Exception);
     tcs.TrySetResult(result);
 }