14

Javascript is disabled on the Client Side, even though i have added below as per documentation.

<RelyingParty>
  <DefaultUserJourney ReferenceId="B2CSignUpOrSignInWithPassword" />
  <UserJourneyBehaviors>
   <ScriptExecution>Allow</ScriptExecution>
  </UserJourneyBehaviors>
  ...
</RelyingParty>

When i try to upload the Custom Policy, i get an error - "Please use page contract in content definitions when enabling JavaScript." Cannot find anything related to this error in documentation.

Tried to add metadata to content definitions, using datauri -

<ContentDefinition Id="api.localaccountpasswordreset">  
  <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
 <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:1.1.0</DataUri>
  ...
 </ContentDefinition>

Expect javascript to work on client side login pages

veejar
  • 141
  • 1
  • 3

4 Answers4

7

If you are still facing the errors, then replace the DataUri tag from

<DataUri>urn:com:microsoft:aad:b2c:elements:idpselection:1.2.0</DataUri> to <DataUri>urn:com:microsoft:aad:b2c:elements:contract:providerselection:1.2.0</DataUri>

for the ContentDefinition api.idpselections and api.idpselections.signup.

Burgan
  • 880
  • 1
  • 7
  • 24
Sandesh Segu
  • 83
  • 1
  • 6
  • Not just the 3 DataUri you listed, ALL of them in use ... ex i missed one: `unifiedssp` and threw same error as OP mentioned – felickz Feb 16 '21 at 21:52
3

I facing the same problem, to correct I follow this steps(for custom policies):

First: in _Base.Xml go to ContentDefinitions and find for DataUri, change all old uris to new like this link https://learn.microsoft.com/en-us/azure/active-directory-b2c/contentdefinitions#migrating-to-page-layout

Second: ensure that you have the word "contract" between your elements and your page identifier, example: change this urn:com:microsoft:aad:b2c:elements:globalexception:1.2.0 for this urn:com:microsoft:aad:b2c:elements:contract:globalexception:1.2.0

Third: in your specific Custom Policie, find for RelyingParty and add the ScriptExecution element to the UserJourneyBehaviors element of RelyingParty

some like this

<RelyingParty>
  <DefaultUserJourney ReferenceId="B2CSignUpOrSignInWithPassword" />
  <UserJourneyBehaviors>
    <ScriptExecution>Allow</ScriptExecution>
  </UserJourneyBehaviors>
  ...
</RelyingParty>

Fourth: upload the base.xml, upload your custom policy.xml and enjoy!

greetings from Brasil.

  • This helped me, and also considering this page: https://azure.microsoft.com/en-us/updates/public-preview-azure-active-directory-b2c-supports-javascript-with-page-contract-in-custom-policies/ – HowToTellAChild Sep 06 '21 at 06:55
1

If someone is still facing error, then you should replace all the data URIs in your content definitions with the one's defined in the below url:

https://learn.microsoft.com/en-us/azure/active-directory-b2c/contentdefinitions#migrating-to-page-layout

Use the new data URI instead of Old one everywhere in your policy and this will fix the issue. Mine was fixed using the same approach. Not only that but the Microsoft documentation clearly states that "If you intend to use JavaScript, you need to define a page layout version with page contract version for all of the content definitions in your custom policy".

Refer the url: https://learn.microsoft.com/en-us/azure/active-directory-b2c/javascript-samples

0

It's work for me Only when I update all ContentDefinition with contract Like, It's take my time

SignUpOrSignin.xml

<UserJourneyBehaviors>
  ...
  <ScriptExecution>Allow</ScriptExecution>
</UserJourneyBehaviors>

TrustFrameworkExtensions.xml / TrustFrameworkBase.xml

<ContentDefinition Id="api.selfasserted.appfactor.registration">
    <LoadUri>https://raw.githubusercontent.com/mdzzaman/dev-info/master/az/selfasserted-appfactor-registration.html</LoadUri>
    <RecoveryUri>https://raw.githubusercontent.com/mdzzaman/dev-info/master/az/selfasserted-appfactor-registration.html</RecoveryUri>
    <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.6</DataUri>
    <Metadata>
      <Item Key="DisplayName">App Factor</Item>
    </Metadata>
  </ContentDefinition>


 <ContentDefinition Id="api.error">
    <LoadUri>~/tenant/templates/AzureBlue/exception.cshtml</LoadUri>
    <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
    <DataUri>urn:com:microsoft:aad:b2c:elements:contract:globalexception:1.2.1</DataUri>
    <Metadata>
      <Item Key="DisplayName">Error page</Item>
    </Metadata>
  </ContentDefinition>

  <ContentDefinition Id="api.signuporsignin">
    <LoadUri>~/tenant/templates/AzureBlue/unified.cshtml</LoadUri>
    <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
    <DataUri>urn:com:microsoft:aad:b2c:elements:contract:unifiedssp:2.1.4</DataUri>
    <Metadata>
      <Item Key="DisplayName">Signin and Signup</Item>
    </Metadata>
  </ContentDefinition>

... All

Kamruzzaman
  • 1,423
  • 1
  • 12
  • 14