Exemplo n.º 1
0
        public async Task <bool> LoginInteractiveAsync(Func <StoryNode> lazynode)
        {
            var node = lazynode();

            Initialize();
            var ret = false;

            try
            {
                authResult = await clientApp
                             .AcquireTokenInteractive(scopes)
                             .WithPrompt(Prompt.SelectAccount)
                             .WithParentActivityOrWindow(UIParent?.Invoke())
                             .ExecuteAsync();

                IsAuthenticated = true;
                ret             = true;
            }
            catch (MsalException msalex)
            {
                authResult = null;
                node.MessageBuffer?.WriteLine($"Acquiring Token Interactive");
                node.MessageBuffer?.WriteLine(msalex.Message);
                node.MessageBuffer?.WriteLine("(E102)");
            }
            catch (Exception ex)
            {
                authResult = null;
                node.MessageBuffer?.WriteLine($"Acquiring Token Interactive");
                node.MessageBuffer?.WriteLine(ex.Message);
                node.MessageBuffer?.WriteLine("(E101)");
            }
            return(ret);
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            if (clientApp == null)
            {
                IsAuthenticated = false;

                clientApp = PublicClientApplicationBuilder.Create(param.AzureADClientId)
                            .WithAuthority(param.AuthorityAudience)
                            .WithRedirectUri(param.PublicClientRedirectUri)
                            .WithIosKeychainSecurityGroup(param.IosKeychainSecurityGroups)
                            .WithParentActivityOrWindow(() => MainActivity?.Invoke() ?? UIParent?.Invoke())
                            .Build();
            }
        }