Ejemplo n.º 1
0
        public static async Task <IGraphServiceClient> GetApi(AccountSession accountSession)
        {
            var authProvider = new OneDriveAuthenticationProvider(
                OneDriveClientId,
                OneDriveClientSecret);

            await authProvider.AuthenticateByAccountSessionAsync(accountSession);

            var httpProvider = new HttpProvider(ProxyTools.CreateHttpClientHandler(), true);
            var api          = new GraphServiceClient(ApiUrl, authProvider, httpProvider);

            return(api);
        }
Ejemplo n.º 2
0
        public static async Task <IGraphServiceClient> GetApi(AccountConfiguration account)
        {
            if (Cache.ContainsKey(account.Id))
            {
                return(Cache[account.Id]);
            }

            var authProvider = new OneDriveAuthenticationProvider(
                OneDriveClientId,
                OneDriveClientSecret);

            await authProvider.AuthenticateByRefreshTokenAsync(account.Secret);

            var httpProvider = new HttpProvider(ProxyTools.CreateHttpClientHandler(), true);
            var api          = new GraphServiceClient(ApiUrl, authProvider, httpProvider);

            Cache.Add(account.Id, api);

            return(api);
        }
Ejemplo n.º 3
0
        public static async Task <IGraphServiceClient> GetApi(AccountConfiguration account)
        {
            if (Cache.ContainsKey(account.Id))
            {
                return(Cache[account.Id]);
            }

            var authProvider = new OneDriveAuthenticationProvider(CreateOidcFlow(), account.Secret);

            var httpProvider = new HttpProvider(ProxyTools.CreateHttpClientHandler(), true)
            {
                OverallTimeout = Timeout.InfiniteTimeSpan
            };

            var api = new GraphServiceClient(authProvider, httpProvider);

            Cache.Add(account.Id, api);

            return(api);
        }