public AppFlowMetadata(int leaId, ISetupBusiness setupBusiness)
        {
            _lea           = leaId;
            _setupBusiness = setupBusiness;
            var    cred   = setupBusiness.GetClientCredentials(leaId);
            string client = string.Empty;
            string secret = string.Empty;

            if (cred != null)
            {
                client = cred.ClientId;
                secret = cred.ClientSecret;
            }

            _flow = new OfflineAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
            {
                ClientSecrets = new ClientSecrets
                {
                    ClientId     = client,
                    ClientSecret = secret
                },
                Scopes    = new[] { ClassroomService.Scope.ClassroomCourses, ClassroomService.Scope.ClassroomRosters, ClassroomService.Scope.ClassroomProfileEmails },
                DataStore = new ClassroomDataStore(setupBusiness),
            });
        }
示例#2
0
        public async Task <ActionResult> GcPreferences(CancellationToken cancellationToken)
        {
            var edOrgId = _sessionInfo.CurrentAgencyId.GetValueOrDefault();
            var pref    = _setupBusiness.GetGcPreference(edOrgId);
            var model   = new GcPreferenceViewModel();

            if (pref != null)
            {
                model.GcUserEmail          = pref.GcUserEmail;
                model.AllowExternalDomains = pref.AllowExternalDomains;

                var cred = _setupBusiness.GetClientCredentials(edOrgId);
                if (cred != null)
                {
                    model.ClientId     = cred.ClientId;
                    model.ClientSecret = cred.ClientSecret;
                    var task = await Task.Run(async() => await GcSync.TestAsync(this, edOrgId, model.GcUserEmail, _setupBusiness, cancellationToken).ConfigureAwait(true));

                    model.CredentialMessage = task.Message;
                }
            }

            return(View(model));
        }