Пример #1
0
        /// <summary>
        /// Check credentials to access Microsoft OneDrive Cloud Storage.
        /// </summary>
        /// <param name="credentials">requied parameters for Microsoft OneDrive OAuth 2.0 authentication.</param>
        public static bool CheckCredentials(MicrosoftOneDriveCredentials credentials)
        {
            // Initialize the GraphServiceClient.
            GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(credentials.RefreshToken, credentials.ApplicationId, credentials.ApplicationSecret, credentials.Scope, credentials.RedirectUri);

            if (graphClient != null)
            {
                var user = graphClient.Me.Request().GetAsync();
                return(user.Result.DisplayName != string.Empty);
            }
            return(false);
        }
Пример #2
0
        /// <summary>
        /// Uploads given content to a file in the Microsoft OneDrive Cloud Storage with an existing refresh token.
        /// </summary>
        /// <param name="ll">current instance of List & Label</param>
        /// <param name="uploadParameters">requied parameters for Microsoft OneDrive OAuth 2.0 upload silently.</param>
        /// <param name="credentials">requied parameters for Microsoft OneDrive OAuth 2.0 authentication.</param>
        public static void UploadSilently(this Reporting.ListLabel ll, MicrosoftOneDriveUploadParameter uploadParameters, MicrosoftOneDriveCredentials credentials)
        {
            // Initialize the GraphServiceClient.
            GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(credentials.RefreshToken, uploadParameters.ApplicationId, credentials.ApplicationSecret, credentials.Scope, credentials.RedirectUri);

            // Add the file.
            UploadLargeFile(graphClient, uploadParameters.UploadStream, string.Concat(uploadParameters.CloudPath, "/", uploadParameters.CloudFileName));
        }