I added a Native app in my B2C Tenant.
App.xaml.cs code looks like this
public static PublicClientApplication PCA = null;
// Azure AD B2C Coordinates
public static string Tenant = "something.onmicrosoft.com";
public static string ClientID = "*********-0e3a-483a-9e15-7896c524ed1d";
public static string PolicySignUpSignIn = "B2C_1_EmailSignup";
public static string PolicyEditProfile = "B2C_1_PasswordReset";
public static string PolicyResetPassword = "B2C_1_PasswordReset";
public static string[] Scopes = { "https://havethat.onmicrosoft.com/demoapi/demo.read" };
public static string ApiEndpoint = "https://havethat.azurewebsites.net/hello";
public static string AuthorityBase = $"https://login.microsoftonline.com/tfp/{Tenant}/";
public static string Authority = $"{AuthorityBase}{PolicySignUpSignIn}";
public static string AuthorityEditProfile = $"{AuthorityBase}{PolicyEditProfile}";
public static string AuthorityPasswordReset = $"{AuthorityBase}{PolicyResetPassword}";
public static UIParent UiParent = null;
public App()
{
// default redirectURI; each platform specific project will have to override it with its own
PCA = new PublicClientApplication(ClientID, Authority);
PCA.RedirectUri = $"msal{ClientID}://auth";
MainPage = new NavigationPage(new MainPage());
}
info.plist file has the following entry for App ID
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>URL Type 1</string>
<key>CFBundleURLSchemes</key>
<array>
<string>msal********-0e3a-483a-9e15-7896c524ed1d</string>
</array>
</dict>
</array>
on a simple click of a button i have just this code
async void OnSign(object sender, EventArgs e)
{
try
{
AuthenticationResult ar = await App.PCA.AcquireTokenAsync(App.Scopes, GetUserByPolicy(App.PCA.Users, App.PolicySignUpSignIn), App.UiParent);
UpdateUserInfo(ar);
}
catch (Exception ex)
{
}
}
now this code takes me to B2C Login page. after successful login it just stays there. If i press "Done" then it goes back to the app with exception that user cancels authenitcation. Shouldn't it just come back to the app after successful login ?