How to pass hint as domain for azure active directory in xamarin forms?

sagarsagar Member ✭✭

I am working on xamarin forms. Where for login we are using AAD authentication. In our application first user will enter email id then we will validate in our DB if email id exists we are redirecting to Microsoft login page their email id will be binded based on previously entered email id. It will ask for the password. How to do that in xamarin forms?

authority=https://login.windows.net/common

 public Task<AuthenticationResult> Authenticate(authority, string resource, string clientId, string returnUri)
        {
            try
            {
                var authContext = new AuthenticationContext(authority);
                if (authContext.TokenCache.ReadItems().Any())
                {
                    authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
                }


                var uri = new Uri(returnUri);
                var platformParams = new PlatformParameters((Activity)Forms.Context);
                var authResult = authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
                return authResult;
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                return null;
            }
        }
Sign In or Register to comment.