public async Task SignIn(AuthenticationResult authenticationResult) { // Use the authentication result to get an access token this.CurrentToken = await OneDriveClient.GetAccessToken(authenticationResult).ConfigureAwait(false); // Create the OneDrive client, set the token refresh callback to save new tokens. await this.InitializeClient().ConfigureAwait(false); if (this.Relationship.Configuration.InitiallyCreatedUtc != DateTime.MinValue) { Logger.Debug("OneDriveAdapter SignIn successful. Saving relationship configuration."); await this.Relationship.SaveAsync().ConfigureAwait(false); } }
public async Task InitializeClient() { this.oneDriveClient = new OneDriveClient(this.CurrentToken); this.oneDriveClient.TokenRefreshed += (s, e) => { this.CurrentToken = e.NewToken; this.SaveCurrentTokenToConfiguration(); }; // Get the user profile. This will have side effect fo refreshing the token and throw // an exception if the refresh token is expired and the user needs to re-sign-in. this.UserProfile = await this.oneDriveClient.GetUserProfileAsync().ConfigureAwait(false); this.IsInitialized = true; this.InitializationComplete?.Invoke(this, new EventArgs()); }
public OneDriveFileUploadStream(OneDriveClient client, OneDriveUploadSession uploadSession, int fragmentSize) { Pre.ThrowIfArgumentNull(client, nameof(client)); Pre.ThrowIfArgumentNull(uploadSession, nameof(uploadSession)); if (fragmentSize < fragmentSizeBase) { throw new ArgumentOutOfRangeException("The fragement size must be at least " + fragmentSizeBase); } if (fragmentSize % fragmentSizeBase != 0) { throw new ArgumentException("The segement size must be a multiple of " + fragmentSizeBase, nameof(fragmentSize)); } this.client = client; this.UploadSession = uploadSession; this.fragmentSize = fragmentSize; this.bytesRemaining = uploadSession.Length; }
public OneDriveFileUploadStream(OneDriveClient client, OneDriveUploadSession uploadSession) : this(client, uploadSession, DefaultFragmentSize) { }
public OneDriveFileDownloadStream(OneDriveClient client, Uri downloadUri) { this.client = client; this.downloadUri = downloadUri; }