{"id":126,"date":"2022-01-06T09:20:15","date_gmt":"2022-01-06T09:20:15","guid":{"rendered":"https:\/\/blog.citrus-lime.com\/crmc\/?p=126"},"modified":"2022-01-06T09:20:15","modified_gmt":"2022-01-06T09:20:15","slug":"part-3-powerapps-portals-azure-b2c-and-power-apps-portals-user-flow-for-signup-and-signin","status":"publish","type":"post","link":"https:\/\/blog.citrus-lime.com\/crmc\/part-3-powerapps-portals-azure-b2c-and-power-apps-portals-user-flow-for-signup-and-signin\/","title":{"rendered":"Part 3 \u2013 PowerApps Portals: Azure B2C and Power Apps Portals \u2013 User Flow for Signup and Signin"},"content":{"rendered":"\n<p>User Flows define how our contacts will be able to gain access to our portal and make changes to their own user info (like with password resets).&nbsp; To set these up, we need navigate to our \u2018User flows\u2019 tab, under the \u2018Policies\u2019 section in our Azure B2C Tenant<\/p>\n\n\n\n<p>Initially for a new B2C Tenant this will be blank as we will not have any User Flows.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb5_38F5D3BC.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb5_thumb_7B6875F2.png\" alt=\"image_thumb[5]\" title=\"image_thumb[5]\" \/><\/a><\/figure>\n\n\n\n<p><strong>To work with Power Apps Portals, we need to create at least 2 User Flows: the Signup and Signin Flow + the Signin Only Flow.<\/strong><\/p>\n\n\n\n<p>We can create a New User Flow and select the categories for&nbsp;<strong>Sign up and sign in<\/strong>&nbsp;+&nbsp;<strong>Recommended<\/strong>&nbsp;to create the screens and logic in our B2C Tenant for a new Sign In:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb15_7AFC42FD.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb15_thumb_5D89F1F1.png\" alt=\"image_thumb[15]\" title=\"image_thumb[15]\" \/><\/a><\/figure>\n\n\n\n<p><br><br>We then give the Flow a particular Name \u2013 if we follow the defaults from the Microsoft Guides, this will typically be:&nbsp;<em>signup_signin &#8211; Here we can set the Multi-Factor Authentication Settings we want to use for our Directory \u2013 this will typically be down to verification of the incoming user\u2019s email address.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb19_643CFB74.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb19_thumb_3D02B23F.png\" alt=\"image_thumb[19]\" title=\"image_thumb[19]\" \/><\/a><\/figure>\n\n\n\n<p><br>At the bottom of creating the Flow, we can then set the Details we collect from a New User signing up \u2013 this is particularly key for Power Apps Portals as this defines what details will flow from Azure B2C to Portals and ultimately to Dynamics to populate the Fields on the Contact Record for the Portal User.<\/p>\n\n\n\n<p>We can change this Attribute Map after the creation of the Flow \u2013 but initially we can define First Name, Last Name and Email Address.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb24_1F906133.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb24_thumb_316CF500.png\" alt=\"image_thumb[24]\" title=\"image_thumb[24]\" \/><\/a><\/figure>\n\n\n\n<p><strong><br>Once created, we can access the Properties area of the User Flow.<\/strong><\/p>\n\n\n\n<p>In here we need to ensure the&nbsp;<strong>Issuer (iss) Claim<\/strong>&nbsp;is set to use the \u2018tfp\u2019 referenced URL \u2013 this is controlled by a dropdown under the&nbsp;<strong>Token Compatibility Settings<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_06285DF9.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_3AC8BA34.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p>&nbsp;&nbsp;<br><br>With this done, we can drill down into the properties of our new User Flow and find the Issuer URL \u2013 as we will need this to insert into the Site Settings of our Portal. To do this, we open our Signup \/ Signin User Flow, we will now have the option to Run user flow, this will open a right-hand-side panel which will elaborate on the User Flow Settings:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb8_2C8A4144.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb8_thumb_1A417A82.png\" alt=\"image_thumb[8]\" title=\"image_thumb[8]\" \/><\/a><\/figure>\n\n\n\n<p><strong><br>We can click this URL to open the JSON definition of the Flow:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_07F8B3C0.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_239D3FB6.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p><br>The \u2018issuer\u2019 here being the setting we need as our&nbsp;<em>B2C\/Authority<\/em>&nbsp;and one of our&nbsp;<em>B2C\/ValidIssuers<\/em>&nbsp;to configure into the Portal Site Settings.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br>Portal Site Settings<\/h3>\n\n\n\n<p>Now we have our B2C Tenant Setup with our two initial User Flows \u2013 we can configure the Site Settings in Power App Portals to communicate with them.<\/p>\n\n\n\n<p>This is done in the Portal Management App within Dynamics 365, and then into Site Settings.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb11_7C62F680.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb11_thumb_310352BC.png\" alt=\"image_thumb[11]\" title=\"image_thumb[11]\" \/><\/a><\/figure>\n\n\n\n<p><strong><br><br>We then have a number of settings to set based on our User Flow:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Authentication\/OpenIdConnect\/B2C\/Authority<\/strong><\/td><td><a href=\"https:\/\/crmcstestb2c.b2clogin.com\/tfp\/be96a25c-a4d3-40f7-aceb-b1b60904da5b\/b2c_1_signup_signin\/v2.0\/\"><strong><em>https:\/\/crmcstestb2c.b2clogin.com\/tfp\/be96a25c-a4d3-40f7-aceb-b1b60904da5b\/b2c_1_signup_signin\/v2.0\/<\/em><\/strong><\/a><\/td><\/tr><tr><td><strong>Authentication\/OpenIdConnect\/B2C\/ClientId<\/strong><\/td><td>{App Registration \u2013 Client ID}<\/td><\/tr><tr><td><strong>Authentication\/OpenIdConnect\/B2C\/DefaultPolicyId<\/strong><\/td><td>B2C_1_signup_signin<\/td><\/tr><tr><td><strong>Authentication\/OpenIdConnect\/B2C\/RedirectUri<\/strong><\/td><td><a href=\"https:\/\/%7Bmyportalname%7D.powerappsportals.com\/signin-B2C\">https:\/\/{myportalname}.powerappsportals.com\/signin-B2C<\/a><\/td><\/tr><tr><td><strong>Authentication\/OpenIdConnect\/B2C\/RegistrationClaimsMapping<\/strong><\/td><td><strong>firstname<\/strong>=https:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/<strong>givenname<\/strong>,<strong>lastname<\/strong>=<br>https:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/<strong>surname<\/strong><\/td><\/tr><tr><td><strong>Authentication\/OpenIdConnect\/B2C\/ValidIssuers<\/strong><\/td><td><a href=\"https:\/\/crmcstestb2c.b2clogin.com\/tfp\/be96a25c-a4d3-40f7-aceb-b1b60904da5b\/b2c_1_signup_signin\/v2.0\/\"><strong><em>https:\/\/crmcstestb2c.b2clogin.com\/tfp\/be96a25c-a4d3-40f7-aceb-b1b60904da5b\/b2c_1_signup_signin\/v2.0\/<\/em><\/strong><\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This configures the Portal to work with the Sign Up and Sign In process we have defined in our Azure B2C Tenant.<\/p>\n\n\n\n<p>The RegistrationClaimsMapping Setting here is how our Attribute Map captured by the B2C Signup process is then mapped to Fields within Dynamics 365 \u2013 so there is a flow of data from the Azure User Account to the Contact Record in CRM.<\/p>\n\n\n\n<p>This set of settings then combines with standard configuration to enable Azure B2C:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Authentication\/OpenIdConnect\/B2C\/AllowContactMappingWithEmail<\/strong><\/td><td>true<\/td><\/tr><tr><td><strong>Authentication\/Registration\/LoginButtonAuthenticationType<\/strong><\/td><td><a href=\"https:\/\/crmcstestb2c.b2clogin.com\/tfp\/be96a25c-a4d3-40f7-aceb-b1b60904da5b\/b2c_1_signup_signin\/v2.0\/\"><strong><em>https:\/\/crmcstestb2c.b2clogin.com\/tfp\/be96a25c-a4d3-40f7-aceb-b1b60904da5b\/b2c_1_signup_signin\/v2.0\/<\/em><\/strong><\/a><\/td><\/tr><tr><td><strong>HTTP\/Access-Control-Allow-Origin<\/strong><\/td><td><a href=\"https:\/\/crmcstestb2c.b2clogin.com\/tfp\/be96a25c-a4d3-40f7-aceb-b1b60904da5b\/b2c_1_signup_signin\/v2.0\/\">https:\/\/crmcstestb2c.b2clogin.com\/<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Now, we are ready to test our Portals and B2C Setup and see how things are working with the two sync\u2019ed up.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\"><br>Testing<\/h3>\n\n\n\n<p>First off \u2013 we can check our Authentication Settings in our&nbsp;<a href=\"https:\/\/make.powerapps.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Power Apps Maker<\/a>&nbsp;area.<\/p>\n\n\n\n<p>This can be done by highlighting the Portal App \u2013 clicking&nbsp;<strong>Settings<\/strong>&nbsp;\u2013 and then&nbsp;<strong>Authentication Settings<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_09C90987.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_256D957D.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p><br><br>This will open an area that allows us to configure different Identity Providers to work with our Portal \u2013 including the Azure B2C Provider, and view the Settings we have just configured:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_2C209F00.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_4BCF78C8.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p><br><br>If the Power Apps Portal Site has been running prior to us making the Site Settings changes \u2013 then it may be useful to restart the Portal Site from the&nbsp;<strong>Administration<\/strong>&nbsp;area.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_3986B206.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_7950988B.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p><br>This will ensure the Portal has reloaded any updated Settings from our updated Site Settings \u2013 essentially flushing the cache.<\/p>\n\n\n\n<p>Once done, we can open our portal and try signing in and signing up.<\/p>\n\n\n\n<p>When we click to Login, we will notice the URL change from that of our Portal and into the URL we have setup for Azure B2C:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_42E2773A.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_54BF0B07.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p><br>Here we can Sign In or Sign Up Now as our setup of the B2C User Flow would suggest.<\/p>\n\n\n\n<p>Clicking Sign Up Now will allow us to create a New Account in Azure B2C and see this in Dynamics as a Contact.<\/p>\n\n\n\n<p>In this Sign Up, we will see our Attribute Map (First Name + Last Name + Email) and our Multi-Factor Authentication Settings (verification by email) in action:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_297A7400.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_02402ACB.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p><br>Clicking Create will then set us up as a brand new User to the Portal \u2013 and log us in.<\/p>\n\n\n\n<p>Now we have a Portal authentication with Azure B2C.<\/p>\n\n\n\n<p>We can see the New Users appearing in the Configuration Area of the B2C Tenant:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_08F3344E.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_76AA6D8B.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p><br>Plus seeing the User appear as a Contact in Dynamics with a link out to this profile in B2C:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_6461A6C9.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_19020305.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p><br><br>Most importantly \u2013 the end user experience logs into the Portal via an Account secured in Azure B2C:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_6DBD6BFD.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_1895D010.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p><br>This sets us up with our Basic User Flow between Azure B2C \u2013 our next step being two fold:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Making sure we have an additional User Flow for a Self-Service Reset Password<\/li><li>Customising the Login Screen Appearance so we can bespoke this to the Portal.<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<p><strong>Next Article &gt;&gt;<\/strong><strong><\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.crmcs.co.uk\/content\/styling-azure-b2c-for-power-apps-portals.aspx\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Part 4 \u2013 Styling Azure B2C for Power Apps Portals<\/strong><\/a><strong><\/strong><\/p>\n\n\n\n<p><strong>Further Reading\u2026<\/strong><strong><\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.crmcs.co.uk\/what-we-do\/powerapps-portals\/\">https:\/\/www.crmcs.co.uk\/what-we-do\/powerapps-portals\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>User Flows define how our contacts will be able to gain access to our portal and make changes to their own user info (like with password resets).&nbsp; To set these up, we need navigate to our \u2018User flows\u2019 tab, under the \u2018Policies\u2019 section in our Azure B2C Tenant Initially for a new B2C Tenant this<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":""},"categories":[3],"tags":[],"class_list":{"0":"post-126","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-crm"},"featured_image_src":null,"author_info":{"display_name":"jadesmith","author_link":"https:\/\/blog.citrus-lime.com\/crmc\/author\/jadesmith\/"},"_links":{"self":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/comments?post=126"}],"version-history":[{"count":1,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/126\/revisions"}],"predecessor-version":[{"id":127,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/126\/revisions\/127"}],"wp:attachment":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/media?parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/categories?post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/tags?post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}