Giter Club home page Giter Club logo

active-directory-b2c-xamarin-native's Introduction

page_type description languages products urlFragment
sample
This is a simple Xamarin Forms app showcasing how to use MSAL to authenticate users via Azure Active Directory B2C.
csharp
azure
azure-active-directory
xamarin
dotnet
integrate-azure-ad-b2c-xamarin-forms

Integrate Azure AD B2C into a Xamarin forms app using MSAL

This is a simple Xamarin Forms app showcasing how to use MSAL to authenticate users via Azure Active Directory B2C, and access an ASP.NET Web API with the resulting token. For more information on Azure B2C, see the Azure AD B2C documentation.

We have renamed the default branch to main. To rename your local repo follow the directions here.

How To Run This Sample

To run this sample you will need:

  • Visual Studio 2017
  • An Internet connection
  • An Azure AD B2C tenant

If you don't have an Azure AD B2C tenant, you can follow those instructions to create one. If you just want to see the sample in action, you don't need to create your own tenant as the project comes with some settings associated to a test tenant and application; however it is highly recommend that you register your own app and experience going through the configuration steps below.

Step 1: Clone or download this repository

From your shell or command line:

git clone https://github.com/Azure-Samples/active-directory-b2c-xamarin-native.git

[OPTIONAL] Step 2: Get your own Azure AD B2C tenant

You can also modify the sample to use your own Azure AD B2C tenant. First, you'll need to create an Azure AD B2C tenant by following these instructions.

IMPORTANT: if you choose to perform one of the optional steps, you have to perform ALL of them for the sample to work as expected.

[OPTIONAL] Step 3: Create your own policies

This sample uses three types of policies: a unified sign-up/sign-in policy, a profile editing policy, and a reset password policy. Create one policy of each type by following the instructions here. You may choose to include as many or as few identity providers as you wish.

  • IMPORTANT: When setting up your identity providers, be sure to set the redirect URLs to use b2clogin.com.

If you already have existing policies in your Azure AD B2C tenant, feel free to re-use those. No need to create new ones just for this sample.

[OPTIONAL] Step 4: Create your own Web API

This sample calls an API at https://fabrikamb2chello.azurewebsites.net which has the same code as the sample Node.js Web API with Azure AD B2C. You'll need your own API or at the very least, you'll need to register a Web API with Azure AD B2C so that you can define the scopes that your single page application will request access tokens for.

Your web API registration should include the following information:

  • Enable the Web App/Web API setting for your application.
  • Set the Reply URL to the appropriate value indicated in the sample or provide any URL if you're only doing the web api registration, for example https://myapi.
  • Make sure you also provide a AppID URI, for example demoapi, this is used to construct the scopes that are configured in you single page application's code.
  • Once your app is created, open the app's Published Scopes blade and create a scope with read name.
  • Copy the AppID URI and Published Scopes values, so you can input them in your application's code.

[OPTIONAL] Step 5: Create your own Native app

Now you need to register your native app in your B2C tenant, so that it has its own Application ID. Don't forget to grant your application API Access to the web API you registered in the previous step.

Your native application registration should include the following information:

  • Enable the Native Client setting for your application.
  • Once your app is created, open the app's Properties blade and set the Custom Redirect URI for your app to msal<Application Id>://auth.
  • Once your app is created, open the app's API access blade and Add the API you created in the previous step.
  • Copy the Application ID generated for your application, so you can use it in the next step.

[OPTIONAL] Step 6: Configure the Visual Studio project with your app coordinates

  1. Open the solution in Visual Studio.
  2. Open the UserDetailsClient\UserDetailsClient.Core\Features\LogOn\B2CConstants.cs file.
  3. Find the assignment for public static string Tenant and replace the value with your tenant name.
  4. Find the assignment for public static string TentantRedirectUrl and replace the value with your tenant redirect url. In the past, login.microsoftonline.com was used, now you should be using {tenant_name}.b2clogin.com. For more information on changing redirect URL's see here.
  5. Find the assignment for public static string ClientID and replace the value with the Application ID from Step 5.
  6. Find the assignment for each of the policies public static string PolicyX and replace the names of the policies you created in Step 3.
  7. Find the assignment for the scopes public static string[] Scopes and replace the scopes with those you created in Step 4.

[OPTIONAL] Step 6a: Configure the iOS project with your app's return URI

  1. Open the UserDetailsClient.iOS\info.plist file in a text editor (opening it in Visual Studio won't work for this step as you need to edit the text)
  2. In the URL types, section, add an entry for the authorization schema used in your redirectUri.
<array>
 <dict>
   <key>CFBundleURLName</key>
   <string>active-directory-b2c-xamarin-native</string>
   <key>CFBundleURLSchemes</key>
   <array>
     <string>msal[Enter_the_Application_Id_Here]</string>
   </array>
   <key>CFBundleTypeRole</key>
   <string>None</string>
 </dict>
</array>

where [Enter_the_Application_Id_Here] is the identifier you copied in step 2. Save the file.

[OPTIONAL] Step 6b: Configure the Android project with your app's return URI

  1. Open the UserDetailsClient.Droid\MsalActivity.cs file.
  2. Replace [Enter_the_Application_Id_Here] with the identifier you copied in step 2.
  3. Save the file.
  [Activity]
  [IntentFilter(new[] { Intent.ActionView },
        Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault },
        DataHost = "auth",
        DataScheme = "msal[Enter_the_Application_Id_Here]")]
  public class MsalActivity : BrowserTabActivity
  {
  }

Step 7: Run the sample

  1. Choose the platform you want to work on by setting the startup project in the Solution Explorer. Make sure that your platform of choice is marked for build and deploy in the Configuration Manager.
  2. Clean the solution, rebuild the solution, and run it.
  3. Click the sign-in button at the bottom of the application screen. The sample works exactly in the same way regardless of the account type you choose, apart from some visual differences in the authentication and consent experience. Upon successful sign in, the application screen will list some basic profile info for the authenticated user and show buttons that allow you to edit your profile, call an API and sign out.
  4. Close the application and reopen it. You will see that the app retains access to the API and retrieves the user info right away, without the need to sign in again.
  5. Sign out by clicking the Sign out button and confirm that you lose access to the API until the exit interactive sign in.

Running in an Android Emulator

If you have issues with the Android emulator, please refer to this document for instructions on how to ensure that your emulator supports the features required by MSAL.

About the code

The structure of the solution is straightforward. All the application logic and UX reside in UserDetailsClient (portable). MSAL's main primitive for native clients, PublicClientApplication, is initialized as a static variable in App.cs. At application startup, the main page attempts to get a token without showing any UX - just in case a suitable token is already present in the cache from previous sessions. This is the code performing that logic:

protected override async void OnAppearing()
{
    UpdateSignInState(false);

    // Check to see if we have a User in the cache already.
    try
    {
        AuthenticationResult ar = await App.PCA.AcquireTokenSilent(App.Scopes,
                                                                   GetUserByPolicy(App.PCA.Users, App.PolicySignUpSignIn))
                                            .WithAuthority(App.PolicySignUpSignIn)
                                            .ExecuteAsync();
        UpdateUserInfo(ar);
        UpdateSignInState(true);
    }
    catch (Exception)
    {
        // Doesn't matter, we go in interactive mode
        UpdateSignInState(false);
    }
}

If the attempt to obtain a token silently fails, we do nothing and display the screen with the sign in button. When the sign in button is pressed, we execute the same logic - but using a method that shows interactive UX:

var windowLocatorService = DependencyService.Get<IParentWindowLocatorService>();

AuthenticationResult ar = await App.PCA.AcquireTokenInteractive(App.Scopes)
                                        .WithAccount(GetUserByPolicy(App.PCA.Users, 
                                                                     App.PolicySignUpSignIn)
                                        .WithParentActivityOrWindow(() => windowLocatorService?.GetCurrentParentWindow()))
                                        .ExecuteAsync();

The Scopes parameter indicates the permissions the application needs to gain access to the data requested through subsequent web API call (in this sample, encapsulated in OnCallApi). Scopes should be input in the following format: https://{tenant_name}.onmicrosoft.com/{app_name}/{scope_value}

The .WithParentActivityOrWindow() is used in Android to tie the authentication flow to the current activity, and is ignored on all other platforms. That code ensures that the authentication flows occur in the context of the current activity.

The sign out logic is very simple. In this sample we have just one user, however we are demonstrating a more generic sign out logic that you can apply if you have multiple concurrent users and you want to clear up the entire cache.

var accounts = await App.GetAccountsAsync();
foreach (var account in accounts.ToArray())
{
    App.PCA.Remove(account);
}

Android specific considerations

The platform specific projects require only a couple of extra lines to accommodate for individual platform differences.

UserDetailsClient.Droid requires one extra line in the MainActivity.cs file. In OnActivityResult, we need to add

AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);

That line ensures that control goes back to MSAL once the interactive portion of the authentication flow ended.

iOS specific considerations

UserDetailsClient.iOS only requires one extra line, in AppDelegate.cs. You need to ensure that the OpenUrl handler looks as the snippet below:

public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
    AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
    return true;
}

Once again, this logic is meant to ensure that once the interactive portion of the authentication flow is concluded, the flow goes back to MSAL.

In order to make the token cache work and have the AcquireTokenSilentAsync work multiple steps must be followed :

  1. Enable Keychain access in your Entitlements.plist file and specify in the Keychain Groups your bundle identifier.
  2. In your project options, on iOS Bundle Signing view, select your Entitlements.plist file for the Custom Entitlements field.
  3. When signing a certificate, make sure XCode uses the same Apple Id.

More information

For more information on Azure B2C, see the Azure AD B2C documentation homepage.

active-directory-b2c-xamarin-native's People

Contributors

acomsmpbot avatar aiwangmicrosoft avatar bartlannoeye avatar benbtg avatar bgavrilms avatar codemillmatt avatar danieldobalian avatar dependabot[bot] avatar dstrockis avatar genriquez avatar gladjohn avatar gsacavdm avatar jennyf19 avatar jmprieur avatar kengaderdus avatar markti avatar markzuber avatar neha-bhargava avatar parakhj avatar pmaytak avatar sameerk-msft avatar supernova-eng avatar trwalke avatar vibronet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

active-directory-b2c-xamarin-native's Issues

How to specify custom URI for xamarin.forms mobile app for registration link

How to specify custom URI for xamarin.forms mobile app when the user clicks on Register link on Azure B2C directory in sign-in page provided by Azure B2C directory.

In Azure portal, created custom link with URI "MyApplicatin://register". The link is visible in Azure login page in mobile application, but clicking on that link nothing is happening in the mobile app.

ApiEndpoint confusion/ check

Hi, just a quickie: what do I use as the ApiEndpoint, in your case:

https://fabrikamb2chello.azurewebsites.net/hello

I have followed all your steps: I have the B2C Tenant in the Azure Directory that holds my subscription (lets call it ADD1), I have the Applications and policies in a second directory (lets call it ADD2),.

in ADD1 I have added an App Service with the URL https://add1appservice.azurewebsites.net.

I have added this https://add1appservice.azurewebsites.net as the ApiEndPoint, but am getting a 401 error when clicking on "Call API" in the iOS app.

I can create users, login, signout fine however...

I should also point out that your sample worked great out of the box using https://fabrikamb2chello.azurewebsites.net/hello.

Many thanks.

Errors when authenticating

I have a Xamarin Forms app using the package and in general it works really well. I am able to login and get a token that I am able to use for access to my web api etc.

Before each call to the API I am doing the following to authenticate silently.

`AuthenticationResult ar = await App.AuthenticationClient.AcquireTokenSilentAsync(ApplicationSettings.Scopes, Authentication.GetUserByPolicy(App.AuthenticationClient.Users, ApplicationSettings.PolicySignUpSignIn), ApplicationSettings.Authority, forceRefreshToken);

            if (ar != null)
            {
                using (HttpClient client = new HttpClient(new NativeMessageHandler() { Timeout = TimeSpan.FromMilliseconds(30000) }))
                {...}}` 

This works most of the time, but sometimes I am getting exceptions like this:

Value cannot be null. Parameter name: key
and
An item with the same key has already been added. Key: Accept
and
An item with the same key has already been added. Key: User-Agent

This happens on every call until my app is restarted and then it all starts working again.

Is this just that the token has expired or something? Should I be asking the user to login again if any of these exceptions come back?

The version I am using in my app is: 1.1.1-preview0040

Thanks,

After signing up once, cookies storing password and cannot signout and signin with different user

  1. Go to
    https://github.com/Azure-Samples/active-directory-b2c-xamarin-native
    download xamarin sample code ,configure policies and your tenant
  2. Run the code
  3. Click on signup signin
  4. Signup with local account
  5. Click on signout
  6. click on signup sign

Actual: It should allow to signup/sign in with different user
automatically signing in with signed up user crdentials
Video: \scratch2\scratch\v-jytati\Android\5554_android 5_23_2016 2_25_07 PM.mp4

Offline access doesn't work for basic login without an API

Hi there. I am using basically the same implementation in my Xamarin iOS native app as the Forms demo.

I am not trying to access a web api.I am just using AD B2C for sign in. I do not, therefore, get an Access Token back, which makes sense. I do get an ID token.

The problem I have is that when offline I would expect calling 'AcquireTokenSilentAsync' would return a success if we have previously signed in successfully, and are within within the signup policy expiration window.

What I find is that if I sign in, exit the app, turn off internet, relaunch and try to sign in again immediately, the request just fails and I get a HTTP exception.This means users always need to have internet to launch the app.

As far as I can tell, openId and offline_access are both now implicit scopes - adding them results in an error message saying so. However, I am forced to put in a dummy scope for the auth request - it has to be dummy as I have no api to add a scope for since it's a 'sign in only' client app. This feels like a weird design, unless I am missing something. You can no longer just put your Client (App) ID in to get ID token refresh as suggested elsewhere.

If I have internet, it all works fine and acquire silent succeeds.

Is it the case that without an Access token (for an api) I get no offline ability? The Expires property in the AuthentictionResult is default DateTime 1970 blah blah, which is supposed to be for the Access token which is null.

Clarify Sample's Suitability for UWP

Hi,

It took me a long time to realize this sample project was most suitable for UWP. I had been struggling with the active-directory-b2c-dotnet-desktop project, probably because I'm a WPF developer and think of UWP as its successor moreso than a companion to the other mobile frameworks. Could we add a tag or something to the project description to mark this project as a UWP sample?

Thanks,
Andrew

AcquireTokenAsync throws a NullReferenceException on iOS, on both simulator and device.

Regardless of what I seem to do, I get a NullReferenceException when calling PublicClientApplication's AcquireTokenAsync. I can reproduce this in the sample code without changing a single line of it, as well as in my own project's code. I've got things working properly on the Android side.

Has anyone else come across this?

As far as I know, my Entitlements.plist is set up correctly.

Here's the stack trace:

{System.NullReferenceException: Object reference not set to an instance of an object at Microsoft.Identity.Client.PublicClientApplication+d__22.MoveNext () [0x0003a] in <772466974f16475694ca93a5f7a70108>:0 --- End of stacโ€ฆ}

at Microsoft.Identity.Client.PublicClientApplication+d__22.MoveNext () [0x0003a] in <772466974f16475694ca93a5f7a70108>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <3c7b99a36820490fb2cbc5a6fc6b06d8>:0 at Microsoft.Identity.Client.PublicClientApplication+<AcquireTokenAsync>d__8.MoveNext () [0x0009b] in <772466974f16475694ca93a5f7a70108>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <3c7b99a36820490fb2cbc5a6fc6b06d8>:0

MsalClientException when using custom sign in policy

We're using an identity provider with SAML integration with the new MSAL client, when we use the default sign in policy (B2C_1_Default) the authentication token comes back fine, when we use the custom policy (which works fine for the old experimental ADAL library) we get the following error:

MsalClientException: client info is null

It looks like the response object doesnt include a couple things, causing errors

Response when using the custom policy

{
    "access_token": "...",
    "id_token": "...",
    "token_type": "Bearer",
    "not_before": "1495204421",
    "expires_in": "3600",
    "expires_on": "1495208021",
    "resource": "...",
    "refresh_token": "...",
    "refresh_token_expires_in": "1209600"
}

Response when using the default policy

{
    "access_token": "...",
    "id_token": "...",
    "token_type": "Bearer",
    "not_before": 1495204558,
    "expires_in": 3600,
    "expires_on": 1495208158,
    "resource": "...",
    "client_info": "...",
    "scope": "... onmicrosoft.com/mobileapi/readwrite",
    "refresh_token": "...",
    "refresh_token_expires_in": 1209600
}

As you can see, the default policy is getting back client_info and scope

Call API

Hello,
I downloaded the code, I have configured the example with the data of my B2C azure, I have created two applications into the b2c tenant: one of native and the other web api, I have followed all the instructions provided, and when I call the api, I get the error: {"Message":"Authorization has been denied for this request."}

The API be made with Asp.net

Can you help me, please?

Toni

Claim not found when running my own service

I can run the unmodified sample just fine, but I'm trying to run it with my own settings. I changed Tenant, ClientId, and PolicyId in Web.config. On the Xamarin side, in App.cs I changed ClientId, SignUpSigninPolicy, Authority, and APIbaseURL to my own settings.

I can create users and authenticate, but the web service throws an exception because string owner = ClaimsPrincipal.Current.FindFirst(obIDClaimType).Value is null. This only happens in my own service; it works fine with vibrotaskservice.azurewebsites.net.

I only use email signup, and no social network identity providers. In my "Sign-up or sign-in policy", I selected three claims. One of those claims is objectId, as shown in this screenshot:

claims

I do not have a separate "Sign-up" or "Sign-in" policy. What could I be doing wrong?

Error: We can't connect to the service you need right now. Check your network connection or try this again later

Hello all,

I have been trying to get this example to work. First Android, then iOS and finally with UWP simply to get better error results. Ideally I would like it working on iOS. I have a B2C client and a web API set up and working. How do I know this? Because I have the "active-directory-b2c-wpf" example working fine.

In the UWP client the application runs when when I click the sign in button a dialog appears with the progress spinner and then after a second or two I get an error message "We can't connect to the service you need right now. Check your network connection or tray again later". If I close this window the client code throws an exception:

Microsoft.Identity.Client.MsalException: WAB authentication failed ---> System.IO.FileNotFoundException: The specified protocol is unknown. (Exception from HRESULT: 0x800C000D)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

If I compare what is going down the wire from the WPF client and the UWP client when the AcquireTokenAsync method is called they differ.

The WPF client sends the following information (xxxx replaces sensitive info):

GET /te/xxxxx.onmicrosoft.com/b2c_1_susi/oauth2/v2.0/authorize?scope=https%3A%2F%2Fxxxxx.onmicrosoft.com%2Fcms%2Faccess+offline_access+openid+profile&response_type=code&client_id=xxxxx&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&client-request-id=fcdb2f65-9ef2-4c0b-af69-cc337d4067d6&x-client-SKU=MSAL.Desktop&x-client-Ver=1.1.0.0&x-client-CPU=x64&x-client-OS=Microsoft+Windows+NT+6.2.9200.0&prompt=select_account&code_challenge=9ErDqtNfDqGU7IFtTVBccVILq49xl_h50xyv8S25cE8&code_challenge_method=S256&state=a006328c-036b-487b-a9e9-0813facaa55a HTTP/1.1

The UWP client sends something of the form:

GET /tfp/xxxxx.onmicrosoft.com/b2c_1_susi/v2.0/.well-known/openid-configuration HTTP/1.1

I have checked and double checked the b2c-xamarin-native code compared to the b2c-wpf and they are identical apart from the call to AcquireTokenAsync.

In WPF it looks like the following:

 authResult = await App.PublicClientApp.AcquireTokenAsync(
               App.ApiScopes,
               GetUserByPolicy(App.PublicClientApp.Users, App.PolicySignUpSignIn),
               UIBehavior.SelectAccount, string.Empty, null, App.Authority);

for UWP it looks like:

 AuthenticationResult ar = await App.PCA.AcquireTokenAsync(
                  App.ApiScopes,
                  GetUserByPolicy(App.PCA.Users, App.PolicySignUpSignIn),
                  App.UiParent);

Do I need to configure something different on the backend to get mobile/UWP clients working or do I need to look elsewhere?

Any help would be appreciated.

Error on a custom screen from Microsoft.Identity.Client using CustomTabs

Xamarin.Android Version: 8.0

Operating System & Version : Microsoft Windows [Version 10.0.14393]

Support Libraries Version : API Level 21 Lollipop

Describe your Issue:

An application to connect to Azure using AD to B2C authentication, is using the Microsoft.Identity.Client, and the version that is working is Custom Tabs 23.3, but when I tried to install through Nudget Microsoft.Identity.Client, this installs version Custom Tabs 26.x.
And when I run the code, it throws the following error,

12-06 02:09:42.177 D/ViewRootImpl@ec13238MainActivity: MSG_WINDOW_FOCUS_CHANGED 0
12-06 02:09:42.181 D/InputMethodManager( 6553): HSI from window - flag : 0 Pid : 6553
12-06 02:09:42.225 V/ActivityThread( 6553): performLaunchActivity: mActivityCurrentConfig={0 1.0 themeSeq = 0 showBtnBg = 0 311mcc480mnc [en_US] ldltr sw360dp w360dp h668dp 480dpi nrml long port ?dc finger -keyb/v/h -nav/h mkbd/h desktop/d s.53}
12-06 02:09:42.251 D/Mono ( 6553): Assembly Ref addref Microsoft.Identity.Client[0xdcdc2e80] -> Xamarin.Android.Support.CustomTabs[0xdc48d560]: 2
12-06 02:09:42.270 D/Mono ( 6553): DllImport searching in: '__Internal' ('(null)').
12-06 02:09:42.270 D/Mono ( 6553): Searching for 'java_interop_jnienv_get_object_field'.
12-06 02:09:42.270 D/Mono ( 6553): Probing 'java_interop_jnienv_get_object_field'.
12-06 02:09:42.270 D/Mono ( 6553): Found as 'java_interop_jnienv_get_object_field'.
An unhandled exception occured.

Steps to Reproduce (with link to sample solution if possible):

Run this code
AuthenticationResult ar = await App.PCA.AcquireTokenAsync(App.Scopes, GetUserByPolicy(App.PCA.Users, App.PolicySignUpSignIn), App.UiParent);

Question: What is MainPageRenderer good for?

Lacking a better place to ask questions, I opened an issue here. I hope this is OK.

What is the MainPageRenderer class good for? It essentially does nothing, but store the active page in a member variable. Additionally, I don't see the class instantiated.

Xamarin Forms UWP App Fails to re-login after initial Login

I am trying to use the sample app, but the UWP version, after originally signing in, now fails whenever I try to sign in again with the error at the bottom.

The iOS app does not encounter this issue, not tried Android. I am running on the latest Windows (1803). In an attempt to remedy I have tried to update all nugets, make UWP target version 1803. Then have even tried upgrading all nuget componets to the latest preview version but still no change.

Not sure what I am missing if the iOS one runs fine.

Error in UWP App:

{Microsoft.Identity.Client.MsalServiceException: Returned user identifier does not match the sent user identifier
at Microsoft.Identity.Client.Internal.Requests.RequestBase.SaveTokenResponseToCache()
at Microsoft.Identity.Client.Internal.Requests.RequestBase.PostTokenRequest()
at Microsoft.Identity.Client.Internal.Requests.RequestBase.d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.PublicClientApplication.d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Identity.Client.PublicClientApplication.d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at TodoAzure.AuthenticationProvider.d__9.MoveNext()
ErrorCode: user_mismatch
StatusCode: 0
Claims: }

Profile edit policy asks users to sign in again although they are already logged in

Hi all,

I've found this issue when I create a edit profile policy in Azure B2C and replicate the snippets from the sample.

The snippet below is from the sample

// KNOWN ISSUE:
// User will get prompted
// to pick an IdP again.
AuthenticationResult ar = await App.PCA.AcquireTokenAsync(App.Scopes, GetUserByPolicy(App.PCA.Users, App.PolicyEditProfile), UIBehavior.SelectAccount, string.Empty, null, App.AuthorityEditProfile, App.UiParent);

Are there any updates on this? Or any workarounds to handle profile editing without sign-in again?

Kind Regards,

Jay

How to define scope?

In the provided example, the following string is presented as the scope and used to acquire the token. However, nowhere in the code or read me is explained clearly how this uri is constructed or defined.

public static string[] Scopes = { "https://fabrikamb2c.onmicrosoft.com/demoapi/demo.read" };

It is only mentioned in Step 4 that "You'll need your own API or at the very least, you'll need to register a Web API with Azure AD B2C so that you can define the scopes that your single page application will request access tokens for"

Does it mean that I have to create a web api to act as an identity provider or this step is optional?

Social IDPs giving error during login

Frequently, upon selecting a social IDP in this sample, the login will fail displaying a correlation ID and generic error message from AAD B2C.

This is due to an improper request being sent to the social IDP by Azure AD B2C. We are investigating and will update here when possible.

For now the recommendation is to use local accounts to complete the sample.

GetUserByPolicy always returns null

Debugging the project, I noticed that the method GetUserByPolicy always returns null when it's called by AcquireTokenSilentAsync or AcquireTokenAsync and the login page doesn't appear. That way, the AuthenticateResult is not set.
On AADB2C/WebAPI it was set AppId URI as "https://{Tenant}/api" and the scope as "read".
On the app, the SignUpSignInPolicy is "B2C_1_susi" and the scope is "https://{Tenant}/api/read.

AcquireTokenSilentAsync fails on User collection can't be null or empty

I'm not clear on the use case for using AcquireTokenSilentAsync. It seems way different workflow from previous version. Now you have to force the user to login into the app each time in order to populate the PublicClientApplication User collection. Before I was able to store the token securely and not have to worry about keeping a user object around. If the token was valid the user had access to the app. There doesn't appear to be way to add a user to the PublicClientApplication User collection beyond having to call the AcquireTokenAsync.

Azure MSAL login issue

Hello guys

I am trying to login using username and password, after signup but getting following error
Microsoft.Identity.Client.MsalServiceException: Returned user identifier does not match the sent user identifier at Microsoft.Identity.Client.Internal.Requests.RequestBase.SaveTokenResponseToCache ()
I am using MSAL for login. and when we try to login with facebook, it works perfectly.

Please check the screen shot

0-cus-d3-f9e42b91d54eeaf0e440b634656ebc15

Sample doesn't work on Android (Nougat)

Tried running the sample on Android Device as well as Genymotion emulator (Android 7.1, API 25) but when we click on SignIn button, the application just gives an UnhandledException with no details.

Followed all the steps mentioned in
https://azure.microsoft.com/en-us/resources/samples/active-directory-b2c-xamarin-native/ and skipped all Optional steps.

The error occurs on

AuthenticationResult ar = await App.PCA.AcquireTokenAsync(App.Scopes, GetUserByPolicy(App.PCA.Users, App.PolicySignUpSignIn), App.UiParent);

Is there any known issue?

System.MissingMethodException: Method 'Android.Support.CustomTabs.CustomTabsIntent.LaunchUrl' not found.

Hi,

Experiencing exception in Azure AD B2C login by using MSAL Library on Android platform with the following two libraries when updated to latest version (26.1.0.1)

  1. Xamarin.Android.Support.CustomTabs (version 26.1.0.1)
  2. Xamarin.Android.Support.v4 (version 26.1.0.1)

Please download sample from the following link:

https://github.com/Azure-Samples/active-directory-b2c-android-native-msal

Exception:
System.MissingMethodException: Method 'Android.Support.CustomTabs.CustomTabsIntent.LaunchUrl' not found.

StackTrace:

MonoDroid( 7659): UNHANDLED EXCEPTION:
MonoDroid( 7659): System.MissingMethodException: Method 'Android.Support.CustomTabs.CustomTabsIntent.LaunchUrl' not found.
MonoDroid( 7659): at Android.App.Activity.n_OnResume (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] :0
MonoDroid( 7659): at (wrapper dynamic-method) S
An unhandled exception occured.

UrL bar when logging in.

When I login using a iOS simulator, it gives me a URL bar at the top. Is it possible to remove this?

Android project won't redirect back to app

I'm a bit new to Azure & Xamarin.Forms and am trying to build a simple login application. I've gone through this tutorial multiple times and can't help but feel like I'm missing something. My application successfully brings me to the login page & allows me to enter my credentials, but when I click login it brings me to a blank screen (as seen below).

screen shot 2018-03-21 at 7 50 26 pm

My android manifest looks like:

<uses-sdk android:minSdkVersion="25" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application> <activity android:name="microsoft.identity.client.BrowserTabActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="msal{app-id-of-native-aad-application}" android:host="auth" /> </intent-filter> </activity> </application> </manifest>

The redirect URI of my native app is set to msal{app-id-of-native-aad-application}://auth and the reply URI of my api (though from what i've seen this doesn't really matter) is set to https://localhost:44316/

I've changed the variables in the PCL as follows:

public static readonly string Tenant = "qalog.onmicrosoft.com"; // Domain/resource name from AD B2C
        public static readonly string ClientID = "{app-id-of-native-aad-application}"; // Application ID from AD B2C
        public static string PolicySignUpSignIn = "B2C_1_LoginApp"; // Policy name from AD B2C
        public static string PolicyEditProfile = "B2C_1_EditProf";
        public static string PolicyResetPassword = "B2C_1_ResetPass";

        public static readonly string[] Scopes = { "https://qalog.onmicrosoft.com/api/read", "https://qalog.onmicrosoft.com/api/user_impersonation"}; // Leave blank unless additional scopes have been added to AD B2C
        public static string ApiEndpoint = "https://fabrikamb2chello.azurewebsites.net/hello";

        public static string AuthorityBase = $"https://login.microsoftonline.com/tfp/{Tenant}/"; // Doesn't require editing
        public static string Authority = $"{AuthorityBase}{PolicySignUpSignIn}"; // Doesn't require editing

Am I missing something/does anyone have suggestions?

Redirect URI not working on Android

Hi all,

I followed the procedure described in the readme. On iOS it works as expected, but on Android, I can provide my credentials but then I get "This site can't be reached", It shows the expected redirect url msal{appid}://auth/?state={very long token} ERR_UNKOWN_URL_SCHEME.

This is my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
	<uses-sdk android:minSdkVersion="15" />
	<application android:label="XXXXXX"></application>
  <activity android:name="com.microsoft.windowsazure.mobileservices.authentication.RedirectUrlActivity" >
    <intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="msal{appid}" android:host="auth" />
    </intent-filter>
  </activity>
</manifest>

I have replaced {appid} with the id of my native application, not that of the API application.

My MainActivity contains the overridden OnActivityResult from the sample.

Please advise.

Xamarin.Android can not run without chrome

I download the sample and change the configuration to myself, it works well in iOS and UWP. But it doesn't work in android. I know that run this example , Custom Chrome Tabs is required in android device, so it chrome is required too. But it is not receptive that ask my end users to install the chrome before using my app.I want to say that this library very fits our needs, but now I have to discard this library, and look for a new library.

So is there any plan to remove the reliance on Custom Chrome Tabs?
If I missed anything or there is any workaround, please let me know.

Thank you in advance.

Android slow login redirection

The sample runs fine on an Android device. Is it normal that it takes quite a while (at least 15 seconds) to redirect the user to the login page?

AccessToken is null

Hi,

Following all steps i have created (i have not added any scope) all elements, i am able to log in and user is registered, but AccessToken property is always null, however IdToken has a value, i suppouse it's a configuration issue but i do not know where is it.

Some people tells about is also necessary configure application authentication/authorization in Azure and set "Azure Active Directory" as provider, but i do knot now if it's really necessary because i do not see any special effect.

I do not know if it's possible provide Azure configuration example used for this application code, i really appreciate it.

Thanks,

Issue logging in with Twitter

Hello.

Ran the project without modification to Visual Studio 2017 for Mac on iOS simulator: iPhone X iOS 11.4.

All the logins worked with the exception of the Twitter login.
(This is after pressing the Twitter login button -- but with no opportunity to type in a username/pass)

It created an error message that displayed as:
Sorry, but we're having trouble signing you in.
We track these error automatically, but if the problem
persists feel free to contact us.
In the meantime, please try again.

Correlation ID: b52514e3-1f88-4d87-b3b7-0cfb590e188d
Timestamp: 2018-07-02 20:43:28Z
AADB2C: An exceptions has occurred.

Is this something you have seen before?

Sample does not run on iOS - Android throws intermittent exceptions

Build env: Visual studio 2017 15.8.3

Running this sample "out of the box" on Android (simulator and device) Android API 23-27 often gives an error with invalid Oauth2 reponse that it cannot parse. This happens with both my AD / tenant and the sample connection info "as is".

Running this sample "out of the box" on iOS (simulator and device) iOS 11-11.4 gives an error regarding type lookups and never displays any webview. Also tried setting the useEmbeddedWebview where the UiParent is constructed... Project is in Debug, set to do not link.

"System.TypeLoadException: Could not set up parent class, due to: Could not load type of field 'Microsoft.Identity.Core.UI.WebviewBase:asWebAuthenticationSession' (5) due to: Could not resolve type with token 0100004d (from typeref, class/assembly AuthenticationServices.ASWebAuthenticationSession, Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065) assembly:Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 type:AuthenticationServices.ASWebAuthenticationSession member:(null) signature:<none> assembly:/Users/wilks/Library/Developer/CoreSimulator/Devices/99CBFEFD-157F-49AB-8A7A-FFFA876F5BE0/data/Containers/Bundle/Application/A7F2516F-663C-4CDD-BF23-64BEF59C058F/UserDetailsClientiOS.app/Microsoft.Identity.Client.dll type:WebviewBase member:(null) signature:<none>\n  at Microsoft.Identity.Client.PublicClientApplication.CreateWebAuthenticationDialog (Microsoft.Identity.Client.UIParent parent, Microsoft.Identity.Client.UIBehavior behavior, Microsoft.Identity.Core.RequestContext requestContext) [0x00015] in <f077f6b3700d43e3adf74b7a06b732ac>:0 \n  at Microsoft.Identity.Client.PublicClientApplication+<AcquireTokenForUserCommonAsync>d__23.MoveNext () [0x00088] in <f077f6b3700d43e3adf74b7a06b732ac>:0 \n--- End of stack trace from previous location where exception was thrown ---\n  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 \n  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 \n  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 \n  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 \n  at Microsoft.Identity.Client.PublicClientApplication+<AcquireTokenAsync>d__16.MoveNext () [0x000a6] in <f077f6b3700d43e3adf74b7a06b732ac>:0 \n--- End of stack trace from previous location where exception was thrown ---\n  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 \n  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 \n  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 \n  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 \n  at UserDetailsClient.Core.MainPage+<OnSignInSignOut>d__1.MoveNext () [0x0012d] in D:\\Dev\\Research\\adb2c\\UserDetailsClient\\UserDetailsClient.Core\\MainPage.xaml.cs:26 "

Does this sample work on iOS for anyone? I can find NO working samples or code snippets for B2C on iOS with Xamarin forms anywhere. Untested on iOS 10.x

System.TypeLoadException from UIParent on Android

I was using this code to setup my B2C code after updating to Microsoft.Identity.Client version 1.1.0 and ran into the following problem when I ran it on Android:

The code compiled and the Build completed but when I debugged it on my Galaxy S5, it crashed before making it to the MainActivity OnCreate() method. Here is the exception it listed:

06-10 14:34:03.883 E/mono (22353): Unhandled Exception:
06-10 14:34:03.883 E/mono (22353): System.TypeLoadException: Could not load type of field 'MyApp.App:UiParent' (16) due to: Could not resolve type with token 0100008c (from typeref, class/assembly Microsoft.Identity.Client.UIParent, Microsoft.Identity.Client, Version=1.1.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae) assembly:Microsoft.Identity.Client, Version=1.1.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae type:Microsoft.Identity.Client.UIParent member:
06-10 14:34:03.883 E/mono-rt (22353): [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'MyApp.App:UiParent' (16) due to: Could not resolve type with token 0100008c (from typeref, class/assembly Microsoft.Identity.Client.UIParent, Microsoft.Identity.Client, Version=1.1.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae) assembly:Microsoft.Identity.Client, Version=1.1.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae type:Microsoft.Identity.Client.UIParent member:

Do you know how to get around this error, or what it is caused by?

For XF Android Developers - AquireTokenAsync Unhandled Exception Resolved

I was facing an error in the Android project with MSAL. The Ios and UWP projects performed correctly. The login page was shown and I was able to get the AADB2C authentication. But when I run Android, the application broke with an Unhandled Excpetion. I did a search and I found the solution. The versions of Nuget Packages!
MSAL needs Xamarin.Android.Support.CustomTabs v23.3. With newer versions, I faced the same error. So don't update it, and use the Xamarin Foms v2.4.x. My Android project targets the Oreo version, 26 and runs properly.

<?xml version="1.0" encoding="utf-8"?> <packages> <package id="CommonServiceLocator" version="1.3" targetFramework="monoandroid80" /> <package id="Microsoft.CSharp" version="4.4.0" targetFramework="monoandroid80" /> <package id="Microsoft.Identity.Client" version="1.1.0-preview" targetFramework="monoandroid80" /> <package id="Microsoft.NETCore.Platforms" version="2.0.1" targetFramework="monoandroid80" /> <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="monoandroid80" /> <package id="NETStandard.Library" version="2.0.1" targetFramework="monoandroid80" /> <package id="Newtonsoft.Json" version="10.0.3" targetFramework="monoandroid80" /> <package id="Prism.Core" version="7.0.0.168-pre" targetFramework="monoandroid80" /> <package id="Prism.Forms" version="7.0.0.168-pre" targetFramework="monoandroid80" /> <package id="Prism.Unity.Forms" version="7.0.0.168-pre" targetFramework="monoandroid80" /> <package id="System.AppContext" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Collections" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.ComponentModel.TypeConverter" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Console" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Globalization" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Globalization.Calendars" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.IO" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.IO.Compression" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.IO.FileSystem" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Linq" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Linq.Expressions" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Net.Http" version="4.3.3" targetFramework="monoandroid80" /> <package id="System.Net.Primitives" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Net.Sockets" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.ObjectModel" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Reflection" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Runtime" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Runtime.Handles" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Runtime.Serialization.Formatters" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="monoandroid80" /> <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="monoandroid80" /> <package id="System.Text.Encoding" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Threading" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Threading.Tasks" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Threading.Timer" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Xml.XDocument" version="4.3.0" targetFramework="monoandroid80" /> <package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="monoandroid80" /> <package id="Unity" version="4.0.1" targetFramework="monoandroid80" /> <package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid80" /> <package id="Xamarin.Android.Support.CustomTabs" version="23.3.0" targetFramework="monoandroid80" /> <package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid80" /> <package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid80" /> <package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid80" /> <package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="monoandroid80" /> <package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="monoandroid80" /> <package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid80" /> <package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid80" /> <package id="Xamarin.Forms" version="2.4.0.91020" targetFramework="monoandroid80" /> </packages>

Email login (no identity provider) dont work in 1.1.0

I have successfully implemented an email login, without any identity provider with the 1.0.304142221-alpha. I update to 1.1.0_preview and I cannot do it. When I try to log in with my test address ([email protected]), it's seems to try to log in to the Microsoft identity service. As my password are not the same in Microsoft identity provider and in my own B2C service, it fails to log in.

How to set the redirect uri on the portal

I have configured the iOS and Android projects returned uri according to the instruction. However, I am not sure how to configure the custom redirect uri on the portal.
The example available on the documentation is as follows:

Custom Redirect URI: com.onmicrosoft.contoso.appname://redirect/path
Enter a redirect URI with a custom scheme. Make sure you choose a good redirect URI and do not include special characters such as underscores.

When I try to construct a custom uri similar to the example com.onmicrosoft.{tenant}.{appname}://redirect/path

I get the uri mismatch error and when I set the uri something like

msal[APPLICATIONID]://auth

I get the unknow url scheme error and a message that the site can't be reached.

Can someone please explain what I should set as the custom uri on the portal?

Not clear as to the purpose of Scope parameter

There is no documentation or explanation in the demo sample as the purpose of the Scope parameter. I'm not clear on where in Azure AAD B2C tenant this parameter gets assigned. Right now I've set this to empty string and it passes through the validation.

Cancelling Sign up throws exception

Hello,

The application throws exception when I do below
Click sign in button -> Click sign up -> click cancel sign up
This exception found when testing on Android.

Please check below screenshot
2017-09-20_3-53-19

Can't install pacakge Microsoft.Identity.Client

When i use vs2017 to create a xamarin forms project use pcl template , and then use command "Install-Package Microsoft.Identity.Client -Version 1.1.0-preview" to install package for pcl project ,it show error as following:

Executing nuget actions took 218.01 ms
Found package 'Microsoft.Identity.Client 1.1.0-preview' in 'D:\bley\MOP\MOP-Master\packages'.
Install failed. Rolling back...
Package 'Microsoft.Identity.Client.1.1.0-preview' does not exist in project 'MOP'
Executing nuget actions took 691.56 ms
Could not install package 'Microsoft.Identity.Client 1.1.0-preview'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

App.PCA.Users Count is 0 after the call to the AcquireTokenAsync on 11.X iOS Simulators

App.PCA.Users Count remains 0 after the call to the App.PCA.AcquireTokenAsync only on the iOS 11.2 Simulator
Line 50:
AuthenticationResult ar = await
App.PCA.AcquireTokenAsync(App.Scopes, GetUserByPolicy(App.PCA.Users, App.PolicySignUpSignIn), App.UiParent);

As a result, call to the App.PCA.AcquireTokenSilentAsync at line 116
throws "Null user provided" exception since GetUserByPolicy returns null

I successfully tried:
Android emulator API 25
Android tablet on API 23
iPhone 8 plus (Running on iOS 11.2)
iPhone 9.1 Simulator
I'm using VS for MAC
screen shot 2017-12-04 at 7 14 27 pm
screen shot 2017-12-04 at 7 49 44 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.