public static async Task <Microsoft.OneDrive.OneDriveClient> GetOneDriveClientAsync(string clientId, OneDriveScopes[] scopes, IRefreshTokenHandler refreshTokenHandler = null)
        {
            LiveAuthClient authClient = new LiveAuthClient(clientId, refreshTokenHandler);
            var            authScopes = from s in scopes select OAuthScopeAttribute.OAuthScopeForEnumValue(s);

            LiveLoginResult loginResult = await authClient.IntializeAsync(authScopes);

            if (loginResult.Status == LiveConnectSessionStatus.Connected)
            {
                return(new OneDriveClient(new LiveConnectClient(loginResult.Session)));
            }

            string startUrl = authClient.GetLoginUrl(authScopes);
            string endUrl   = OAuthDesktopEndPoint;
            FormMicrosoftAccountAuth authForm = new FormMicrosoftAccountAuth(startUrl, endUrl);

            DialogResult result = await authForm.ShowDialogAsync();

            if (DialogResult.OK == result)
            {
                return(await OnAuthComplete(authClient, authForm.AuthResult));
            }

            return(null);
        }
        public static async Task<Microsoft.OneDrive.OneDriveClient> GetOneDriveClientAsync(string clientId, OneDriveScopes[] scopes, IRefreshTokenHandler refreshTokenHandler = null)
        {
            LiveAuthClient authClient = new LiveAuthClient(clientId, refreshTokenHandler);
            var authScopes = from s in scopes select OAuthScopeAttribute.OAuthScopeForEnumValue(s);

            LiveLoginResult loginResult = await authClient.IntializeAsync(authScopes);
            if (loginResult.Status == LiveConnectSessionStatus.Connected)
            {
                return new OneDriveClient(new LiveConnectClient(loginResult.Session));
            }

            string startUrl = authClient.GetLoginUrl(authScopes);
            string endUrl = OAuthDesktopEndPoint;
            FormMicrosoftAccountAuth authForm = new FormMicrosoftAccountAuth(startUrl, endUrl);

            DialogResult result = await authForm.ShowDialogAsync();
            if (DialogResult.OK == result)
            {
                return await OnAuthComplete(authClient, authForm.AuthResult);
            }

            return null;
        }