public async Task <LiveLoginResult> SignIn() { // First try silent login LiveLoginResult loginResult = await AuthClient.InitializeAsync(Scopes); // Sign in to the user's Microsoft account with the required scope. // // This call will display the Microsoft account sign-in screen if // the user is not already signed in to their Microsoft account // through Windows 8. // // This call will also display the consent dialog, if the user has // has not already given consent to this app to access the data // described by the scope. // // Change the parameter of LoginAsync to include the scopes // required by your app. if (loginResult.Status != LiveConnectSessionStatus.Connected) { loginResult = await AuthClient.LoginAsync(Scopes); } UpdateAuthProperties(loginResult.Status); return(loginResult); }
private async Task AttemptRefreshToken() { //If the user is signed in and has not yet signed out, we will attempt to refresh the token if necessary before sending a create page request if (IsSignedIn) { //Attempt to use the refresh token acquired previously since the user has not explicitly signed out LiveLoginResult loginWithRefreshTokenResult = await AuthClient.InitializeAsync(Scopes); UpdateAuthProperties(loginWithRefreshTokenResult.Status); } }
public async Task SignOut() { LiveLoginResult loginResult = await AuthClient.InitializeAsync(Scopes); // Sign the user out, if they are connected if (loginResult.Status != LiveConnectSessionStatus.NotConnected) { AuthClient.Logout(); } UpdateAuthProperties(LiveConnectSessionStatus.NotConnected); }
public async Task <LiveLoginResult> SilentSignIn() { try { LiveLoginResult loginResult = await AuthClient.InitializeAsync(Scopes); UpdateAuthProperties(loginResult.Status); return(loginResult); } catch (Exception) { return(null); } }