public MobileServicesDataSource(string userId, IAccessTokenRetriever accessTokenRetriever, ILogger logger)
 {
     currentUserId                             = userId;
     refreshActivitySchedule                   = false;
     refreshDataTrends                         = false;
     internetAccessIsAvailable                 = false;
     isRegisteredForNetworkStatusChanges       = false;
     isAuthenticating                          = false;
     cacheRetriever                            = new CacheRetriever();
     this.accessTokenRetriever                 = accessTokenRetriever;
     this.accessTokenRetriever.LoginCompleted += accessTokenRetriever_LoginCompleted;
     this.logger = logger;
 }
Example #2
0
        public GraphService(IMemoryCache memoryCache, IConfiguration configuration, IAccessTokenRetriever tokenRetriever, ITelemetryService telemetryService)
        {
            _memoryCache      = memoryCache ?? throw new ArgumentNullException(nameof(memoryCache));
            _tokenRetriever   = tokenRetriever ?? throw new ArgumentNullException(nameof(tokenRetriever));
            _telemetryService = telemetryService ?? throw new ArgumentNullException(nameof(telemetryService));

            _redirectUri     = configuration.GetValue <string>("AzureAd:CallbackPath");
            _aadInstance     = configuration.GetValue <string>("AzureAd:Instance");
            _appId           = configuration.GetValue <string>("AzureAd:ClientId");
            _tenantId        = configuration.GetValue <string>("AzureAd:TenantId");
            _graphResourceId = configuration.GetValue <string>("AzureAd:GraphResourceId");

            // This code takes the value from the user-secrets capability in dotnet
            // running "dotnet user-secrets list" will list all secrets
            // we don't want it in the appsettings.json file
            _appSecret = configuration.GetValue <string>("Authentication:AzureAd:ClientSecret");
            if (string.IsNullOrWhiteSpace(_appSecret))
            {
                throw new ArgumentException("Client Secret is unknown. Terminating.");
            }
        }
 private void accessTokenRetriever_LoginCompleted(IAccessTokenRetriever sender, bool args)
 {
     currentUserId = mobileService.CurrentUser.UserId = accessTokenRetriever.UserId;
     AccessToken   = mobileService.CurrentUser.MobileServiceAuthenticationToken = accessTokenRetriever.AccessToken;
 }