/// <summary> /// Login and create the connection, if necessary. /// </summary> public static async Task Login() { if (Connection == null || !LiveOAuth.IsSignedIn) { // Get an OAuth2 access token through REST. var token = await LiveOAuth.GetAuthToken(); // Initialize connection Connection = new ODConnection("https://api.onedrive.com/v1.0", new OneDriveSdkAuthenticationInfo(token)); } }
/// <summary> /// Verifies if the user is authenticated and connected. /// </summary> private async static Task EnsureConnection() { if (Connection == null || !LiveOAuth.IsSignedIn) { throw new Exception("You're not logged in."); } else { await LiveOAuth.RefreshAuthTokenIfNeeded(); } }
/// <summary> /// Sign out. No effect in universal app. /// </summary> public static async Task Logout() { await LiveOAuth.SignOut(); }