/// <summary>
 /// Instantiates a new OneDriveClient.
 /// </summary>
 public OneDriveClient(
     AppConfig appConfig,
     CredentialCache credentialCache = null,
     IHttpProvider httpProvider = null,
     IServiceInfoProvider serviceInfoProvider = null)
     : base(appConfig, credentialCache, httpProvider, serviceInfoProvider)
 {
 }
示例#2
0
 public LazyServiceInfo (IServiceInfoProvider provider, ServiceAnnouncement service)
 {
     this.provider = provider;
     this.service = service;
     
     this.Build ();
     
     loading.Text = Catalog.GetString (string.Format ("Loading {0}", provider.Name));
 }
 /// <summary>
 /// Instantiates a new OneDriveClient.
 /// </summary>
 public OneDriveClient(
     AppConfig appConfig,
     CredentialCache credentialCache = null,
     IHttpProvider httpProvider = null,
     IServiceInfoProvider serviceInfoProvider = null,
     ClientType clientType = ClientType.Consumer)
     : base(appConfig, credentialCache, httpProvider, serviceInfoProvider, clientType)
 {
 }
示例#4
0
 public AdalClient(
     AppConfig appConfig, 
     CredentialType credentialType, 
     IServiceInfoProvider serviceProvider = null)
     : base(appConfig, credentialType, serviceProvider)
 {
     appConfig.ServiceResource = Constants.Authentication.GraphServiceUrl;
     serviceProvider = new ServiceProvider();
     this.ServiceInformation = _serviceInfoProvider.CreateServiceInfo(appConfig, credentialType).Result;
 }
示例#5
0
        /// <summary>
        /// Constructs a new <see cref="BaseClient"/>.
        /// </summary>
        public BaseClient(
            AppConfig appConfig,
            CredentialCache credentialCache = null,
            IHttpProvider httpProvider = null,
            IServiceInfoProvider serviceInfoProvider = null)
        {

            this.appConfig = appConfig;
            this.credentialCache = credentialCache ?? new CredentialCache();
            this.HttpProvider = httpProvider ?? new HttpProvider(new Serializer());
            this.serviceInfoProvider = serviceInfoProvider ?? new ServiceInfoProvider();
        }
示例#6
0
 /// <summary>
 /// Constructs a new <see cref="BaseClient"/>.
 /// </summary>
 public BaseClient(
     AppConfig appConfig,
     CredentialCache credentialCache = null,
     IHttpProvider httpProvider = null,
     IServiceInfoProvider serviceInfoProvider = null,
     ClientType clientType = ClientType.Consumer)
 {
     this.appConfig = appConfig;
     this.ClientType = clientType;
     this.credentialCache = credentialCache;
     this.HttpProvider = httpProvider ?? new HttpProvider(new Serializer());
     this.serviceInfoProvider = serviceInfoProvider ?? new ServiceInfoProvider();
 }
        /// <summary>
        /// Creates a OneDrive client for use against OneDrive consumer.
        /// </summary>
        /// <param name="appId">The application ID for Microsoft Account authentication.</param>
        /// <param name="returnUrl">The application return URL for Microsoft Account authentication.</param>
        /// <param name="scopes">The requested scopes for Microsoft Account authentication.</param>
        /// <param name="clientSecret">The client secret for Microsoft Account authentication.</param>
        /// <param name="credentialCache">The cache instance for storing user credentials.</param>
        /// <param name="httpProvider">The <see cref="IHttpProvider"/> for sending HTTP requests.</param>
        /// <param name="serviceInfoProvider">The <see cref="IServiceInfoProvider"/> for initializing the <see cref="IServiceInfo"/> for the session.</param>
        /// <returns>The <see cref="IOneDriveClient"/> for the session.</returns>
        public static IOneDriveClient GetMicrosoftAccountClient(
            string appId,
            string returnUrl,
            string[] scopes,
            string clientSecret,
            CredentialCache credentialCache = null,
            IHttpProvider httpProvider = null,
            IServiceInfoProvider serviceInfoProvider = null)
        {
            var appConfig = new AppConfig
            {
                MicrosoftAccountAppId = appId,
                MicrosoftAccountReturnUrl = returnUrl,
                MicrosoftAccountScopes = scopes,
            };

            return new OneDriveClient(appConfig, credentialCache, httpProvider, serviceInfoProvider);
        }
        /// <summary>
        /// Creates an authenticated OneDrive client for use against OneDrive consumer.
        /// </summary>
        /// <param name="appId">The application ID for Microsoft account authentication.</param>
        /// <param name="returnUrl">The application return URL for Microsoft account authentication.</param>
        /// <param name="scopes">The requested scopes for Microsoft account authentication.</param>
        /// <param name="serviceInfoProvider">The <see cref="IServiceInfoProvider"/> for initializing the <see cref="IServiceInfo"/> for the session.</param>
        /// <param name="credentialCache">The cache instance for storing user credentials.</param>
        /// <param name="httpProvider">The <see cref="IHttpProvider"/> for sending HTTP requests.</param>
        /// <returns>The <see cref="IOneDriveClient"/> for the session.</returns>
        public static async Task<IOneDriveClient> GetAuthenticatedMicrosoftAccountClient(
            string appId,
            string returnUrl,
            string[] scopes,
            IServiceInfoProvider serviceInfoProvider,
            CredentialCache credentialCache = null,
            IHttpProvider httpProvider = null)
        {
            var client = OneDriveClient.GetMicrosoftAccountClient(
                appId,
                returnUrl,
                scopes,
                /* clientSecret */ null,
                credentialCache,
                httpProvider,
                serviceInfoProvider);

            await client.AuthenticateAsync();

            return client;
        }
        /// <summary>
        /// Creates an authenticated OneDrive client for use against OneDrive consumer for silent (refresh token) authentication.
        /// </summary>
        /// <param name="appId">The application ID for Microsoft account authentication.</param>
        /// <param name="returnUrl">The application return URL for Microsoft account authentication.</param>
        /// <param name="scopes">The requested scopes for Microsoft account authentication.</param>
        /// <param name="clientSecret">The client secret for Microsoft account authentication.</param>
        /// <param name="refreshToken">The refresh token for silent authentication.</param>
        /// <param name="serviceInfoProvider">The <see cref="IServiceInfoProvider"/> for initializing the <see cref="IServiceInfo"/> for the session.</param>
        /// <param name="credentialCache">The cache instance for storing user credentials.</param>
        /// <param name="httpProvider">The <see cref="IHttpProvider"/> for sending HTTP requests.</param>
        /// <returns>The <see cref="IOneDriveClient"/> for the session.</returns>
        public static async Task<IOneDriveClient> GetSilentlyAuthenticatedMicrosoftAccountClient(
            string appId,
            string returnUrl,
            string[] scopes,
            string clientSecret,
            string refreshToken,
            IServiceInfoProvider serviceInfoProvider,
            CredentialCache credentialCache = null,
            IHttpProvider httpProvider = null)
        {
            var clientServiceInfoProvider = serviceInfoProvider ?? new ServiceInfoProvider();
            var client = OneDriveClient.GetMicrosoftAccountClient(
                appId,
                returnUrl,
                scopes,
                clientSecret,
                credentialCache,
                httpProvider,
                clientServiceInfoProvider) as OneDriveClient;

            if (client.ServiceInfo == null)
            {
                client.ServiceInfo = await clientServiceInfoProvider.GetServiceInfo(
                    client.appConfig,
                    client.credentialCache,
                    client.HttpProvider,
                    client.ClientType);
            }

            client.AuthenticationProvider.CurrentAccountSession = new AccountSession { RefreshToken = refreshToken };

            await client.AuthenticateAsync();

            return client;
        }
 /// <summary>
 /// Creates an authenticated OneDrive client for use against OneDrive consumer for silent (refresh token) authentication.
 /// </summary>
 /// <param name="appId">The application ID for Microsoft account authentication.</param>
 /// <param name="returnUrl">The application return URL for Microsoft account authentication.</param>
 /// <param name="scopes">The requested scopes for Microsoft account authentication.</param>
 /// <param name="refreshToken">The refresh token for silent authentication.</param>
 /// <param name="serviceInfoProvider">The <see cref="IServiceInfoProvider"/> for initializing the <see cref="IServiceInfo"/> for the session.</param>
 /// <param name="credentialCache">The cache instance for storing user credentials.</param>
 /// <param name="httpProvider">The <see cref="IHttpProvider"/> for sending HTTP requests.</param>
 /// <returns>The <see cref="IOneDriveClient"/> for the session.</returns>
 public static Task<IOneDriveClient> GetSilentlyAuthenticatedMicrosoftAccountClient(
     string appId,
     string returnUrl,
     string[] scopes,
     string refreshToken,
     IServiceInfoProvider serviceInfoProvider,
     CredentialCache credentialCache = null,
     IHttpProvider httpProvider = null)
 {
     return OneDriveClient.GetSilentlyAuthenticatedMicrosoftAccountClient(
         appId,
         returnUrl,
         scopes,
         /* clientSecret */ null,
         refreshToken,
         serviceInfoProvider,
         credentialCache,
         httpProvider);
 }
        /// <summary>
        /// Creates an authenticated client using the ADAL app-only authentication flow.
        /// </summary>
        /// <param name="appConfig">
        ///     The <see cref="BusinessAppConfig"/> for the application configuration.
        /// </param>
        /// <param name="serviceInfoProvider">The <see cref="IServiceInfoProvider"/> for initializing the <see cref="IServiceInfo"/> for the session.</param>
        /// <param name="credentialCache">The cache instance for storing user credentials.</param>
        /// <param name="httpProvider">The <see cref="IHttpProvider"/> for sending HTTP requests.</param>
        /// <returns>The <see cref="IOneDriveClient"/> for the session.</returns>
        internal static IOneDriveClient GetClientInternal(
            AppConfig appConfig,
            IServiceInfoProvider serviceInfoProvider,
            AdalCredentialCache credentialCache,
            IHttpProvider httpProvider)
        {
            if (string.IsNullOrEmpty(appConfig.ActiveDirectoryAppId))
            {
                throw new OneDriveException(
                    new Error
                    {
                        Code = OneDriveErrorCode.AuthenticationFailure.ToString(),
                        Message = "ActiveDirectoryAppId is required for authentication."
                    });
            }

            return new OneDriveClient(
                appConfig,
                credentialCache ?? new AdalCredentialCache(),
                httpProvider ?? new HttpProvider(),
                serviceInfoProvider ?? new AdalServiceInfoProvider(),
                ClientType.Business);
        }
 public ServiceInfoManager(IServiceInfoProvider mServiceInfo)
 {
     serviceInfoDataProvider = mServiceInfo;
 }
 public ServiceAwareACPIShutdownMethod(IServiceInfoProvider serviceInfoProvider) {
     _serviceInfoProvider = serviceInfoProvider;
 }
示例#14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="appConfig"></param>
 /// <param name="credentialType"></param>
 /// <param name="serviceProvider"></param>
 public BaseClient(AppConfig appConfig, CredentialType credentialType, IServiceInfoProvider serviceProvider = null)
 {
     this._appConfig           = appConfig;
     this.CredentialType       = credentialType;
     this._serviceInfoProvider = serviceProvider ?? new ServiceProvider();
 }
示例#15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="appConfig"></param>
 /// <param name="credentialType"></param>
 /// <param name="serviceProvider"></param>
 public BaseClient(AppConfig appConfig, CredentialType credentialType, IServiceInfoProvider serviceProvider = null)
 {
     this._appConfig = appConfig;
     this.CredentialType = credentialType;
     this._serviceInfoProvider = serviceProvider ?? new ServiceProvider();
 }
示例#16
0
 public ServiceAwareACPIShutdownMethod(IServiceInfoProvider serviceInfoProvider)
 {
     _serviceInfoProvider = serviceInfoProvider;
 }