/// <summary> /// Initialize OneDrive service /// </summary> /// <param name="appClientId">Application Id Client. Could be null if AccountProviderType.OnlineId is used</param> /// <param name="accountProviderType">Account Provider type. /// <para>AccountProviderType.OnlineId: If the user is signed into a Windows system with a Microsoft Account, this user will be used for authentication request. Need to associate the App to the store</para> /// <para>AccountProviderType.Msa: Authenticate the user with a Microsoft Account. You need to register your app https://apps.dev.microsoft.com in the SDK Live section</para> /// <para>AccountProviderType.Adal: Authenticate the user with a Office 365 Account. You need to register your in Azure Active Directory</para></param> /// <param name="scopes">Scopes represent various permission levels that an app can request from a user. Could be null if AccountProviderType.Adal is used </param> /// <remarks>If AccountProvider</remarks> /// <returns>Success or failure.</returns> public bool Initialize(string appClientId, AccountProviderType accountProviderType = AccountProviderType.OnlineId, OneDriveScopes scopes = OneDriveScopes.ReadWrite | OneDriveScopes.OfflineAccess) { if (accountProviderType != AccountProviderType.OnlineId && string.IsNullOrEmpty(appClientId)) { throw new ArgumentNullException(nameof(appClientId)); } AppClientId = appClientId; if (accountProviderType != AccountProviderType.Adal) { Scopes = OneDriveHelper.TransformScopes(scopes); } IsInitialized = true; _accountProviderType = accountProviderType; return(true); }
/// <inheritdoc/> public bool Initialize(string appClientId, AccountProviderType accountProviderType = AccountProviderType.OnlineId, OneDriveScopes scopes = OneDriveScopes.OfflineAccess | OneDriveScopes.ReadWrite) { if (accountProviderType == AccountProviderType.Adal || accountProviderType == AccountProviderType.Msal) { _instance = new GraphOneDriveService(); return(_instance.Initialize(appClientId, accountProviderType, scopes)); } if (accountProviderType != AccountProviderType.OnlineId && string.IsNullOrEmpty(appClientId)) { throw new ArgumentNullException(nameof(appClientId)); } _appClientId = appClientId; if (accountProviderType == AccountProviderType.Msa) { _scopes = OneDriveHelper.TransformScopes(scopes); } _isInitialized = true; _accountProviderType = accountProviderType; return(true); }