gpt4 book ai didi

c# - Live SDK - 尝试在没有 SignInButton 的情况下登录

转载 作者:可可西里 更新时间:2023-11-01 03:13:06 26 4
gpt4 key购买 nike

有没有什么方法可以在不点击登录按钮的情况下登录 Live for 一个 App(Silverlight,WP7 可以)。

我要动态登录我,例如:当你启动应用时,我要登录我。如何在不使用按钮的情况下执行此操作?

最佳答案

我想出了怎么做,所以我决定分享:

using System.Windows;
using Microsoft.Live;

public class LiveLogin
{

private static readonly string[] scopes =
new string[] {
"wl.signin",
"wl.basic",
"wl.calendars",
"wl.calendars_update",
"wl.contacts_calendars",
"wl.events_create" };

private LiveAuthClient authClient;
private LiveConnectClient liveClient;


public LiveLogin()
{
this.authClient = new LiveAuthClient("**your client id here**");
this.authClient.InitializeCompleted += authClient_InitializeCompleted;
this.authClient.InitializeAsync(scopes);
}

private void authClient_InitializeCompleted(object sender, LoginCompletedEventArgs e)
{
if (e.Status == LiveConnectSessionStatus.Connected)
{
this.liveClient = new LiveConnectClient(e.Session);
}
else
{
this.authClient.LoginCompleted += authClient_LoginCompleted;
this.authClient.LoginAsync(scopes);
}
}

private void authClient_LoginCompleted(object sender, LoginCompletedEventArgs e)
{
if (e.Status == LiveConnectSessionStatus.Connected)
{
this.liveClient = new LiveConnectClient(e.Session);
MessageBox.Show("Signed");
}
else
{
MessageBox.Show("Failed!");
}
}
}

关于c# - Live SDK - 尝试在没有 SignInButton 的情况下登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10304150/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com