0
votes

I am trying to use this example: https://github.com/Azure-Samples/active-directory-b2c-xamarin-native

It have went through the tutorial 5 times and it worked with the existing fabrikamb2c but when I try to use my own b2c tenant I get errors when clicking sign in on both iOS (Safari cannot open the page because the address in invalid) and Android (blank screen) when it calls IPublicClientApplication.AcquireTokenInteractive()

For iOS - From the PublicClientApplicationBuilder logging, it's trying to go to this url:

https://mycompany.b2clogin.com/tfp/mycompany.onmicrosoft.com/b2c_1_results_mobile_app_staging/oauth2/v2.0/authorize?scope=user.read+openid+profile+offline_access&response_type=code&client_id=xxxxxxxx-yyyy-40c1-804e-13190d66ccc6&redirect_uri=msalxxxxxxxx-yyyy-40c1-804e-13190d66ccc6:%2F%2Fauth&client-request-id=ef26ee69-9f31-4b22-943b-3d497a54e580&x-client-SKU=MSAL.Xamarin.iOS&x-client-Ver=4.25.0.0&x-client-OS=14.4&x-client-DM=iPhone&prompt=select_account&code_challenge=DfZ3m6w1WX5hE4SfzlugJNMggJrAZY3H8t288cBybk8&code_challenge_method=S256&state=cf886b1c-3353-4b05-b300-bb6e1f040b672de723bb-634e-460f-bfc5-e79698061b48

but if I use this format (updated from https://docs.microsoft.com/en-us/azure/active-directory-b2c/user-flow-overview) it works

https://mycompany.b2clogin.com/mycompany.onmicrosoft.com/oauth2/v2.0/authorize?client_id=xxxxxxxx-yyyy-40c1-804e-13190d66ccc6&redirect_uri=https%3A%2F%2Fjwt.ms&response_mode=form_post&response_type=id_token&scope=openid&nonce=dummy&state=12345&p=B2C_1_results_mobile_app_staging

I don't understand why AcquireTokenInteractive() in code is putting the userflow name (B2C_1_results_mobile_app_staging) in the path part of the url while the other one puts it as querystring parameter for p...

I have the iOS Redirect URL set up in the app registration's authentication:

iOS redirect URL

and here is the userflow:

enter image description here

Here is my pinfo.list

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>com.yourcompany.UserDetailsClient</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>msalxxxxxxxx-yyyy-40c1-804e-13190d66ccc6</string>
        </array>
    </dict>
</array>

anyway, any guidance would be appreciated I am quite confused by all this.. been reading docs for a few days it's not "clicking" for me. thank you.

1
Make sure that you had set redirect URLs to b2clogin.com .Check docs.microsoft.com/en-us/azure/active-directory-b2c/b2clogin . You could also post the issue to github.com/Azure-Samples/active-directory-b2c-xamarin-native/… .Lucas Zhang
Lucas thanks for response but I am not sure how this is related? the redirect URLs for mobile apps are in format "msauth.com.yourcompany.UserDetailsClient://auth" for iOS and msauth://UserDetailsClient.Droid/c6HkKZl%2BQxeNM4hJxxxxxxxxxx for android... ? yes I know i can post on the github project i may do that... thank youdan

1 Answers

0
votes

actually it was my configuration on the authentication settings on azure - I didn't have it checked. Sheesh. I knew it was something easy. I was out in the weeds with having other redirect URIs in the Android and iOS sections ... enter image description here