Esempio n. 1
0
        private static async Task <string> GetUserNameByCredentialProvider()
        {
            AuthenticationConfig config = AuthenticationConfig.ReadFromJsonFile("appsettings.json");

            PublicClientApplicationOptions options = new PublicClientApplicationOptions
            {
                ClientId = config.PublicClientId
            };


            var application = PublicClientApplicationBuilder.CreateWithApplicationOptions(options)
                              .WithRedirectUri(config.RedirectUri)
                              .WithAuthority(AzureCloudInstance.AzurePublic, config.Tenant)
                              .Build();

            UsernamePasswordProvider authProvider = new UsernamePasswordProvider(application, ApplicaionScopes);
            await application.AcquireTokenByUsernamePassword(ApplicaionScopes, LogonName, Passcode).
            ExecuteAsync();

            await authProvider.ClientApplication.AcquireTokenByUsernamePassword(ApplicaionScopes, LogonName, Passcode).
            ExecuteAsync();

            PublicGraphClient = new GraphServiceClient(authProvider);


            User me = await PublicGraphClient.Me.Request().GetAsync();

            Console.WriteLine($"Logged in as [{me.DisplayName}] @ {DateTime.Now.ToString()}.");
            Console.WriteLine();
            return(me.Id);
        }
Esempio n. 2
0
        private async static Task ReadChannelData()
        {
            AuthenticationConfig config = AuthenticationConfig.ReadFromJsonFile("appsettings.json");
            var channelInfoFile         = config.ChannelsConfig;


            ChannelStore channelInfo = ChannelStore.ReadFromJsonFile(channelInfoFile);

            if (channelInfo != null && channelInfo.Channels.Any())
            {
                Channels.AddRange(channelInfo.Channels);
            }
            else
            {
                Console.WriteLine("No Channels to List");
            }
        }
Esempio n. 3
0
        public static async Task Main(string[] args)
        {
            try
            {
                await ReadChannelData();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }

            try
            {
                AuthenticationConfig config = AuthenticationConfig.ReadFromJsonFile("appsettings.json");
                LogonName = config.UserName;
                var passCode = config.Passcode;

                var x = passCode.ToCharArray();

                x.ToList().ForEach(x => Passcode.AppendChar(x));


                await GetUserNameByCredentialProvider();

                //await SetUp();
                Console.ForegroundColor = ConsoleColor.Yellow;
                while (loop)
                {
                    Loop();
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }
        }