*我正在开发一个商店应用程序。manage.dev.live.com 上的 ClientID 和 Client Secret 已复制到 Azure 门户上我的移动服务的“身份”选项卡以及 manage.dev 和 Azure 门户上的重定向域匹配。我还从 VS 内部将我的商店应用程序与 manage.dev.live.com 中的应用程序相关联。但我仍然在我的应用程序中收到错误消息。*仅供参考,我为 dev.live.com 和 Azure Portal 使用不同的实时帐户,我不知道这是否有任何影响。在放置断点时,错误发生在以下行 -
LiveLoginResult result = await liveidclient.LoginAsync(new[] { "wl.basic" });
顺便说一句,我确实收到了输入用户名和密码的登录提示。单击确定后,应用程序崩溃并显示消息 - 应用程序未正确配置为使用 Live Connect 服务。要配置您的应用程序,请按照以下说明进行操作
嗨,这是我的例外细节-
Microsoft.Live.LiveAuthException 未处理 HResult=-2146233088 Message=应用程序未正确配置为使用 Live Connect 服务。要配置您的应用程序,请按照http://go.microsoft.com/fwlink/?LinkId=220871上的说明进行操作。Source=Microsoft.Live ErrorCode=invalid_request StackTrace: at Microsoft.Live.LiveAuthClient.d_ 4.MoveNext() --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (任务任务)在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)在 System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at DeltaVMobile.MainPage.<Authenticate>d__4.MoveNext() in MainPage.xaml.cs:line 99
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at DeltaVMobile.MainPage.<OnNavigatedTo>d__0.MoveNext() in MainPage.xaml.cs:line 75
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(Object state)
at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
InnerException:
HResult=-2138701823
Message=Authentication target is invalid or not configured correctly. (Exception from HRESULT: 0x80860001)
Source=mscorlib
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult() at Microsoft.Live.TailoredAuthClient.d _12.MoveNext() --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.Live.TailoredAuthClient.d__0.MoveNext() InnerException:
以下是我正在使用的代码
LiveAuthClient liveidclient = new LiveAuthClient("https://deltavauth.azure-mobile.net/");
while (session == null)
{
if (liveidclient.CanLogout)
{
liveidclient.Logout();
}
LiveLoginResult result = await liveidclient.LoginAsync(new[] { "wl.basic" });
if (result.Status == LiveConnectSessionStatus.Connected)
{
session = result.Session;
LiveConnectClient client = new LiveConnectClient(result.Session);
LiveOperationResult mresult = await client.GetAsync("me");
MobileServiceUser loginresult = await App.MobileService.LoginWithMicrosoftAccountAsync(result.Session.AuthenticationToken);
string title = string.Format("Welcome {0} !", mresult.Result["first_name"]);
var message = string.Format("You are now logged in -{0}", loginresult.UserId);
var dialog = new MessageDialog(title);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
else
{
session = null;
var dialog = new MessageDialog("You must login to use DeltaV", "Login Required");
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
仅供参考,这是教程的 URL - http://www.windowsazure.com/en-us/develop/mobile/tutorials/single-sign-on-windows-8-dotnet/。