internal async Task <AccountSession> ProcessCachedAccountSessionAsync(AccountSession accountSession)
        {
            using (var httpProvider = new HttpProvider(ProxyTools.CreateHttpClientHandler(), true))
            {
                var processedAccountSession = await this.ProcessCachedAccountSessionAsync(accountSession, httpProvider).ConfigureAwait(false);

                return(processedAccountSession);
            }
        }
Exemple #2
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);
        }
        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);
        }
Exemple #4
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);
        }
        public async Task <bool> Claim(Uri uri, string documentTitle)
        {
            var authenticationResponseValues = UrlHelper.GetQueryOptions(uri);

            OAuthErrorHandler.ThrowIfError(authenticationResponseValues);

            string code;

            if (authenticationResponseValues != null && authenticationResponseValues.TryGetValue("code", out code))
            {
                using (var httpProvider = new HttpProvider(ProxyTools.CreateHttpClientHandler(), true))
                {
                    _accountSession =
                        await
                        _oAuthHelper.RedeemAuthorizationCodeAsync(code, OneDriveHelper.OneDriveClientId,
                                                                  OneDriveHelper.OneDriveClientSecret, this.RedirectionUrl.ToString(), OneDriveHelper.Scopes,
                                                                  httpProvider).ConfigureAwait(false);
                }
            }

            return(_accountSession != null);
        }
        private OidcClientOptions CreateBaseOptions()
        {
            var scopes = string.Join(" ", m_scopes);

            var options = new OidcClientOptions
            {
                Authority    = m_authority, ///.well-known/openid-configuration
                ClientId     = m_clientId,
                ClientSecret = m_clientSecret,
                Scope        = scopes,
                Flow         = OidcClientOptions.AuthenticationFlow.AuthorizationCode,
                ResponseMode = OidcClientOptions.AuthorizeResponseMode.FormPost,
                RefreshTokenInnerHttpHandler = ProxyTools.CreateHttpClientHandler(),
                BackchannelHandler           = ProxyTools.CreateHttpClientHandler(),
                LoadProfile = false
            };

            options.Policy.Discovery.ValidateEndpoints  = false;
            options.Policy.Discovery.ValidateIssuerName = false;

            return(options);
        }