Using claim resolvers in generateJson transformation - azure-ad-b2c

I am trying to pass {Culture:LanguageName} and {OAUTH-KV:key} to json body in post request using GenerateJson transfomration method. Unfortunately I am not able to pass it to json, both values are resolved to value "undefined" and skipped during json generation. I managed to make it work but only with
<UserInputType>Readonly</UserInputType>
in claim type.
I don't want to display those values in UI form so leaving readonly input type is not an option for me.
added two ClaimType for each param I want to include in my json
Setup another technical profile with <Item Key="IncludeClaimResolvingInClaimsHandling">true</Item> metadata and included AlwaysUseDefaultValue="true" DefaultValue="{Culture:LanguageName}" in InputClaim
used it in my user journey as first step with ClaimsExchange
Used claims setup in first step in my json transformation

Related

Scraping the user portal for the CDC Wonder API

Sorry in advance for the novel, I've tried to distill this down into something short and sweet, but find it impossible. I'm really hoping someone can shed some light on this problem.
The project: to build a set of utilities to make using the CDC Wonder API easier.
The Wonder API has several endpoints, in the format of /D140 or /D76, for example.
The endpoint must be hit with a POST request, with a set of query parameters sent as an xml string as a POST data parameter.
The query parameter xml string is complicated. The basic format is
<parameter>
<name></name>
<value></value>
</parameter>
</request-parameters>
The names and values are best understood by going to the user-facing query portal. Each one of the inputs (forms, checkboxes, radio buttons, etc) corresponds to a query parameter. Each parameter name is in the form of a code, such as D76.V9 or O_V27fmode. The value may also be a code, or occasionally could be plaintext, such as *All*.
Each endpoint requires a slightly different set of parameters, and the coding for the values is also different. The CDC does not provide documentation on which parameters each endpoint expects. Their documentation specifically tells you that the best way to find this information is by examining the source code of the user-facing query portal, where each element has its name and value embedded as an attribute.
I've found that you can also retrieve these parameters by opening up the dev tools network tab, submitting a filled out query form, and, after the new page loads with your results, checking the POST call's header form data.
One of the utilities I'm trying to build is to scrape the query portal page and programmatically extract the names and values of all parameters from the HTML source code. Seems simple enough and I think I know how to do it.
But, here's the rub: the URL of the user-facing query portal is the same as the URL for the endpoint that you call. In a web browser, going to this URL (https://wonder.cdc.gov/controller/datarequest/D76) sends you to the query form that you fill out. But when you use that same URL in a request in Python, it expects an xml string of query parameters, otherwise you will get an error.
Is it possible to use the requests library to hit this user portal? I tried setting the referrer to https://wonder.cdc.gov/ucd-icd10.html, which is a page you're redirected to before you can get to the query portal, and you must agree to the terms and conditions. I also tried pulling the form data out of the network tab and sent it as an xml string with my POST request, and got a 500 back -- it's expecting the query parameters (including a specific parameter agreeing to the terms of use, as outlined in the documentation). Here's an example of the code I'm using:
xml_string = '''<query-parameters>
<parameter><name>stage</name> <value>about</value> </parameter> <parameter> <name>saved_id</name> <value></value> </parameter> <parameter> <name>action-I Agree</name> <value>I Agree</value> </parameter> </query-parameters> '''
data = {'request_xml': xml_string}
response = requests.post('https://wonder.cdc.gov/controller/datarequest/D76')
print(response.text)
print(response)
Really curious to know how to crack this nut, what am I missing here? How should I be approaching this problem?
Long time after you asked the question but I think the issue is with the post request is made and also the contents of your data variable.
Also just a note that it should be 'result-parameters' instead of 'query-parameters' in your xml_string.
It does seem that the documentation has improved a lot:
https://github.com/alipphardt/cdc-wonder-api/blob/master/CDC%2BWONDER%2BAPI%2BExample.ipynb
Here's how I think you can fix this:
xml_string = \
'''<query-parameters>
<parameter>
<name>stage</name>
<value>about</value>
</parameter>
<parameter>
<name>saved_id</name>
<value></value>
</parameter>
</query-parameters> '''
url = 'https://wonder.cdc.gov/controller/datarequest/D76' ## or D140
param_name = 'request_xml'
url = "https://wonder.cdc.gov/controller/datarequest/D76"
response = requests.post(url, data={"request_xml": xml_string, "accept_datause_restrictions": "true"})

Azure AD B2C: Extract single item from Json Array

I'm trying to extract a single email address from an array of email addresses (stored in the otherEmails attribute). I thought I could use the GetSingleValueFromJsonArray claims transformation. But, I get the following error:
The InputClaims mismatched in ClaimsTransformation with id
"GetEmailFromJson" with TransformationMethod
"GetSingleValueFromJsonArray". The following InputClaims were declared
in the Policy but were not expected by the TransformMethod:
[StringCollection]inputJsonClaim. The following InputClaims were
expected by the TransformMethod but were not declared in the Policy:
[String]inputJsonClaim.
It's complaining that my input is a collection of strings -which it is. The error says it wants a 'string' as input. The documentation also states that it wants a string. But then I'm confused how this should ever work with an array, as the name implies.
Essentially, I just want to return the email address in the id_token when using OpenID Connect. But with B2C it seems I can't set the mail field and it's null when I query for it. So, I've taken to using the otherEmails field. But I really only plan on storing a single email in it. Thus, I want to return the email claim as a single value claim, and not an array.
Update
After a bit more digging, I realized I can accomplish my goal without using a ClaimsTransformation. I can just map the 'signInNames.emailAddress' to 'email'.
<OutputClaim ClaimTypeReferenceId="signInNames.emailAddress" PartnerClaimType="email"/>
You can use the GetSingleItemFromStringCollection claims transformation to get the first item in the string collection.

Same output claim from multiple technical profiles

If the same output claim is defined in multiple technical profiles, what is the expected behavior?
Particularly if a technical profile emits an output claim and another technical profile that executes later defines the same output claim but does not emit one at run time, what is the expected behavior?
If there are two different OrchestrationSteps, each containing a TechnicalProfile that emits the same claim, then the TechnicalProfile from the later step will "overwrite" the value of the claim if such a claim is emitted.
Lets take a specific (although somewhat made-up) example.
Step 1 uses a TechnicalProfile for a SelfAsserted page that asks the user for their first name via "OutputClaim ClaimTypeReferenceId="givenName"" . The user fills in the name "John" on this page, and continues.
Step 2 uses a TechnicalProfile for a ClaimsExchange with Google, which may also emit a first name via "OutputClaim ClaimTypeReferenceId="givenName"".
However, it is possible that the user did or did not register their first name when creating their account at Google. If the first name is available (lets say with the name "Lingeshwaran"), then Google will emit that claim, and B2C will consume it. In this case, the final resulting value after step 2 for givenName will be "Lingeshwaran".
If the user did not fill in their first name when creating their Google account, then it will be missing from the claims that Google emits in their token. As a result, the existing "givenName" claim will not be overwritten, and the resulting value after step 2 for givenName will be "John".

How to access nested Part properties in Email Workflow?

I have a Registration ContentType, which contains a ContentPicker field for a Building Item, which contains a Geolocation Part with some properties like Latitude and Longitude.
When a new Registration is Published, it triggers a custom Workflow that sends out an email. In the body of the email I can get to the fields of the Building using tokens like this: {Content.Fields.Registration.Building.Content.Fields.Building.Address}
How can I get to the property values of the Geolocation Part contained within the Building? Can I do something like this? {Content.Fields.Registration.Building.Content.Parts.Geolocation.Latitude}
I'm new to Orchard and I can't figure out how it's structured. Can this be done out of the box or will I have to write a custom token?
If you know which content item to take from the content picker field (for example if it always is only one), then the following might work:
{Content.Fields.Registration.Building.Content.Fields.Building.ContentItems[0].Geolocation.Latitude}
This is assuming your Building field is configured to pick content types with a Geolocation part

API to display filled in tags in PNG format

We are looking for a way to have functionality similar to the following api method which returns a requested page in PNG format (non editable format):
https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST API References/Get a Page Image.htm
but with the ability to display the values for any custom, etc. tags that have been filled in. Currently, no tags or values are displayed regardless of whether they have been filled in.
Does any know a way to do this?
I don't believe you can bring back the tab values with the page image when the envelope is still in process, I think only completed envelopes will show that info.
You'll most likely have to make a separate API call to retrieve the recipient entered tab values. Have a look at the Get Envelope Recipient Status API call, and more importantly, it's one optional parameter. Details of the call are:
URL:
/accounts/{accountId}/envelopes/{envelopeId}/recipients
HTTP Method:
GET
Parameters:
The only required parameter is the envelope ID. If the optional query include_tabs is set to true, the tabs associated with the recipient are returned. If the optional query include_extended is set to true, the extended properties are returned.

Resources