Can AWS Cognito adminCreateUser send a temporary password? - node.js

The Amazon Cognito adminCreateUser documentation on TemporaryPassword states:
This parameter is not required. If you do not specify a value, Amazon
Cognito generates one for you.
How does the user ever get it? At first I thought it would get emailed to the user, but that doesn't seem to be the case. Then I thought maybe it would come back in the response. Nope.
Here's the code I'm calling in my node JS Lambda function:
adminCreateUser(
{
"UserPoolId": "us-east-1_XXXXXXXX",
"Username": "roger__mailinator.com",
"DesiredDeliveryMediums": [
"EMAIL"
],
"ForceAliasCreation": false,
"MessageAction": "SUPPRESS",
"UserAttributes": [
{
"Name": "given_name",
"Value": "Rodger"
},
{
"Name": "family_name",
"Value": "Ribbit"
},
{
"Name": "name",
"Value": "Rodger Ribbit"
},
{
"Name": "email",
"Value": "roger#mailinator.com"
},
{
"Name": "custom:title",
"Value": "Animation Designer"
},
{
"Name": "custom:company",
"Value": "76"
}
]
}, function(error, data) {
if (error) {
console.log("Error adding user to cognito: " + error, error.stack);
//...
} else {
console.log("Received back from cognito: " + JSON.stringify(data));
//...
}
});
and here's the response I get:
Received back from cognito:
{
"User": {
"Username": "roger__mailinator.com",
"Attributes": [
{
"Name": "custom:title",
"Value": "Animation Designer"
},
{
"Name": "sub",
"Value": "1cd612a0-0da0-4e7b-84c7-30570fab80a9"
},
{
"Name": "name",
"Value": "Rodger Ribbit"
},
{
"Name": "given_name",
"Value": "Rodger"
},
{
"Name": "family_name",
"Value": "Ribbit"
},
{
"Name": "email",
"Value": "roger#mailinator.com"
},
{
"Name": "custom:company",
"Value": "76"
}
],
"UserCreateDate": "2017-03-30T18:31:34.283Z",
"UserLastModifiedDate": "2017-03-30T18:31:34.283Z",
"Enabled": true,
"UserStatus": "FORCE_CHANGE_PASSWORD"
}
}
Where does the password go? Are we supposed to guess it? :-)

I think it's because you are passing "MessageAction": "SUPPRESS". That would suppress the sending of the email.
The temporary password is emailed to the user and he needs to reset it upon the first login.

The answer is that the user email needs to be verified before they'll receive it. So you need to modify the user attribute on email to be verified. See: https://stackoverflow.com/a/43033722/491553

Related

Alexa CBT Test: Failed Test due to DeepQuery=True

My colleagues and I have been working to fix a reported issue on our Amazon Alexa CBT Test regarding the value “DeepQuery=true”.
Our code has been modified, so that every state change is reported automatically and all the used interfaces have the properties “proactivelyReported” and “retrievable” set to true.
As has been suggested by the WWA-Support we used the Smart Home Debugger of the Developer Console to validate the ReportEvents (e.g. Discovery or ChangeReport) and we checked the state of our device on the “View Device State” page (both pages are referenced on: https://developer.amazon.com/en-US/docs/alexa/smarthome/debug-your-smart-home-skill.html).
For debugging purposes we scaled our device capabilities down to just the PowerController. The AddOrUpdateReport of Alexa.Discovery looks to our eyes now exactly as expected/documented. Same goes for the ChangeReport, which we proactively send right after the AddOrUpdateReport (Two sample-Reports for both are provided at the end).
Unfortunately we are still faced with the issue, that “DeepQuery=true” on the “View Device State” page.
If we set the interface property “retrievable” to false, “DeepQuery=false”, but the Alexa-App does not retain the current state of the device. In this configuration the Alexa-App can only be used to send commands, which unfortunately will lead to other test cases to fail.
Does anyone know how to solve this issue?
How can we set “proactivelyReported” and “retrievable” to true and have “DeepQuery=false”?
Any help would be greatly appreciated and I will gladly provide more informations if needed.
Sample AddOrUpdateReport from Smart Home Debugger
{
"header": {
"namespace": "SkillDebugger",
"name": "CaptureDebuggingInfo",
"messageId": "05b030fb-6393-4ae0-80d0-47fc27876f0e"
},
"payload": {
"skillId": "amzn1.ask.skill.055ca62d-3cf8-4f51-a683-9a98b36f4637",
"timestamp": "2021-09-09T13:28:21.629Z",
"dialogRequestId": null,
"skillRequestId": null,
"type": "SmartHomeAddOrUpdateReportSuccess",
"content": {
"addOrUpdateReport": {
"event": {
"header": {
"namespace": "Alexa.Discovery",
"name": "AddOrUpdateReport",
"messageId": "2458b969-7c3e-47e2-ab0b-6e13a999be76",
"payloadVersion": "3"
},
"payload": {
"endpoints": [
{
"manufacturerName": "Our Company Name",
"description": "Our Product Name",
"endpointId": "device--cb12b420-1171-11ec-81f3-cb34e87ea438",
"friendlyName": "Lampe 1",
"capabilities": [
{
"type": "AlexaInterface",
"version": "3",
"interface": "Alexa.PowerController",
"properties": {
"supported": [
{
"name": "powerState"
}
],
"proactivelyReported": true,
"retrievable": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
}
],
"displayCategories": [
"LIGHT"
],
"connections": [],
"relationships": {},
"cookie": {}
}
],
"scope": null
}
}
}
}
}
}
Sample ChangeReport from Smart Home Debugger
{
"header": {
"namespace": "SkillDebugger",
"name": "CaptureDebuggingInfo",
"messageId": "194a96a1-6747-46ba-8751-5c9ef715fd34"
},
"payload": {
"skillId": "amzn1.ask.skill.055ca62d-3cf8-4f51-a683-9a98b36f4637",
"timestamp": "2021-09-09T13:28:23.227Z",
"dialogRequestId": null,
"skillRequestId": null,
"type": "SmartHomeChangeReportSuccess",
"content": {
"changeReport": {
"event": {
"header": {
"namespace": "Alexa",
"name": "ChangeReport",
"messageId": "8972e386-9622-40e6-85e7-1a7d81c79c8a",
"payloadVersion": "3"
},
"endpoint": {
"scope": null,
"endpointId": "device--cb12b420-1171-11ec-81f3-cb34e87ea438"
},
"payload": {
"change": {
"cause": {
"type": "APP_INTERACTION"
},
"properties": [
{
"namespace": "Alexa.PowerController",
"name": "powerState",
"value": "ON",
"timeOfSample": "2021-09-09T13:28:18.088Z",
"uncertaintyInMilliseconds": 500
}
]
}
}
},
"context": {
"properties": []
}
}
}
}
}

Error submitting Sales Order to Acumatica

I'm testing an order submission via Postman, just passing this JSON structure to /SalesOrders.
{
"Details": [
{
"InventoryID": {
"value": "TEST-SKU"
},
"WarehouseID": {
"value": "BUF"
},
"LineNbr": {
"value": 1
},
"OrderQty": {
"value": 2
},
"UnitPrice": {
"value": 285
}
}
],
"CustomerID": {
"value": "0000003759"
},
"Hold": {
"value": false
},
"Description": {
"value": "WEBTEST-1000123456"
},
"ExternalRef": {
"value": "1000123456"
},
"BillToAddressOverride": {
"value": true
},
"ShipToAddressOverride": {
"value": true
},
"Totals": {
"FreightCostIsuptodate": {
"value": true
},
"OverrideFreightPrice": {
"value": true
},
"FreightCost": {
"value": 41.89
},
"Freight": {
"value": 41.89
}
},
"PaymentMethod": {
"value": "APSCRCARD"
},
"NewCard": {
"value": true
},
"PaymentCardIdentifier": {
"value": "APSCRCARD:****-****-****-1234"
},
"PaymentRef": {
"value": "12345678910"
},
"ShipToContact": {
"Attention": {
"value": "Test User"
},
"BusinessName": {
"value": "Testing Company"
}
},
"BillToAddress": {
"AddressLine1": {
"value": "123 Test Lane"
},
"AddressLine2": {
"value": ""
},
"AddressLine3": {
"value": ""
},
"AddressLine4": {
"value": ""
},
"City": {
"value": "Buffalo"
},
"Country": {
"value": "US"
},
"PostalCode": {
"value": "14216"
},
"State": {
"value": "NY"
},
"rowNumber": {
"value": 1
}
},
"ShipToAddress": {
"AddressLine1": {
"value": "123 Test Lane"
},
"AddressLine2": {
"value": ""
},
"AddressLine3": {
"value": ""
},
"AddressLine4": {
"value": ""
},
"City": {
"value": "Buffalo"
},
"Country": {
"value": "US"
},
"PostalCode": {
"value": "14216"
},
"State": {
"value": "NY"
},
"rowNumber": {
"value": 1
}
},
"ShippingSettings": {
"shipVia": {
"value": "BUFFEDEX2DAY"
}
}
}
It's getting hung up when I'm trying to pass over cc information and I'm not exactly sure what to do. It says the Payment Card Identifier field is empty but as you can see I'm passing a value to it.
"SalesOrder.PaymentCardIdentifier: 'Identifier' cannot be empty.\nInserting 'CustomerPaymentMethodC' record raised at least one error. Please review the errors."
I'm not sure if I need to be using a different value but I'm repurposing one that I received on a call to get Sales Orders from Acumatica.
I was curious if I potentially have to add the CustomerPaymentMethod before adding the order? Any help around this would be greatly appreciated.
The Validation message mentions SalesOrder.PaymentCardIdentifier being empty not PaymentCardIdentifier so are you sure you have the correct request format?
Please check the Endpoint to see how this field is being defined in the SalesOrder Entity. That field is not part of the default endpoint - so I can't check it, but perhaps the name is spelled differently.
So it turned out, regarding this, that I was referencing an incorrect endpoint in our system (a custom one as opposed to Default).
I also had to add payment to the Payment sub-object as opposed to the Sales Order object directly.
Thank you everyone for the assistance!

Update Note System field on a PUT request using Endpoint Rest API

Hi I want to set the Note field as part of my PUT request when adding a new activity record in Advanced.
I have my custom endpoint setup and I can insert the activity record no worries except setting the Note system field doesnt seem to do anything?
Here is an example of my JSON for the request
{
"Note": "narrtion test five",
"Summary": {
"value": "Test Task Status"
},
"Type": {
"value": "W"
},
"ActivityDate": {
"value": "2020-03-04T00:00:00"
},
"StartTime": {
"value": "0001-01-01T15:00:00"
},
"Owner": {
"value": "MATTMCD"
},
"Status": {
"value": "Completed"
},
"CostCode": {
"value": "0000"
},
"EarningType": {
"value": "RG"
},
"Billable": {
"value": true
},
"LabourItem": {
"value": "LABOUR-MAT"
},
"Project": {
"value": "PR00000001"
},
"ProjectTask": {
"value": "TESTTASK"
},
"TimeSpent": {
"value": "0:30"
},
"ActivityDetails": {
"value": "narrtion test five"
}
}
Would appreciate some help with this?
Can you try with "note" instead of "Note" ?
{
"note": "narrtion test five",
...
}

How to send to Amazon's Alexa Event Gateway?

I am trying to test sending an event to the Amazon's Event Gateway for my Alexa Smart Home skill using Postman but I keep receiving an 'invalid access token exception.' I have read the Amazon's documentation on this but apparently I am missing something.
When I enable my skill, my Smart Home Lambda receives the AcceptGrant.
{
"directive": {
"header": {
"namespace": "Alexa.Authorization",
"name": "AcceptGrant",
"messageId": "b2862179-bc56-4bb2-ac05-ce55c7a3e977",
"payloadVersion": "3"
},
"payload": {
"grant": {
"type": "OAuth2.AuthorizationCode",
"code": "ANSVjPzpTDBsdfoRSyrs"
},
"grantee": {
"type": "BearerToken",
"token": "Atza|IwEB..."
}
}
}
}
My lambda sends a POST to 'https://api.amazon.com/auth/o2/token' to receive the Access and Refresh tokens. It then stores those tokens. Next, my Lamdba responds with the following:
{
"event": {
"header": {
"namespace": "Alexa.Authorization",
"name": "AcceptGrant.Response",
"messageId": "b2862179-bc56-4bb2-ac05-ce55c7a3e977",
"payloadVersion": "3"
},
"payload": {}
}
}
I then get a message web page that I have successfully linked my skill - all is good.
Next, I try to send an event to Amazon's Alexa event gateway using the Postman app. I put the Access token (I also tried the Refresh token) in the header as a 'BearerToken' type and the in the 'scope' of the 'endpoint' object.
POST https://api.amazonalexa.com/v3/events?Content-Type=application/json&charset=UTF-8
with a header that specifies a Bearer Token (Access token received earlier) and a body that contains the following:
{
"event": {
"header": {
"messageId": "abc-123-def-456",
"namespace": "Alexa",
"name": "ChangeReport",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<access token>"
},
"endpointId": "MySmartSwitch-001"
},
"payload": {
"change": {
"cause": {
"type": "RULE_TRIGGER"
},
"properties": [
{
"namespace": "Alexa.ModeController",
"name": "mode",
"value": "Backup",
"timeOfSample": "2020-01-02T09:30:00ZZ",
"uncertaintyInMilliseconds": 50
}
]
}
}
},
"context": {
"properties": [
{
"namespace": "Alexa.PowerController",
"name": "powerState",
"value": "ON",
"timeOfSample": "2020-01-02T09:30:00Z",
"uncertaintyInMilliseconds": 60000
},
{
"namespace": "Alexa.EndpointHealth",
"name": "connectivity",
"value": {
"value": "OK"
},
"timeOfSample": "2020-01-02T09:30:00Z",
"uncertaintyInMilliseconds": 0
}
]
}
}
The response received is '401 Unauthorized'
{
"header": {
"namespace": "System",
"name": "Exception",
"messageId": "95bd23c3-76e6-472b-9c6d-74d436e1eb61"
},
"payload": {
"code": "INVALID_ACCESS_TOKEN_EXCEPTION",
"description": "Access token is not valid."
}
}
I figured out the issue. I was mistakenly sending parameters: Content-Type=application/json and charset=UTF-8 as well including them in the header - my bad. You just need to include them in the header.

OpenAM /json/authenticate ReST api behaves differently on different servers

I am calling the OpenAM /json/authenticate api for a realm. The request details are as below. The issue is on one server the response received contains the tokenId directly and on other it gives the authId with callbacks. Both servers are exactly same with same configuration. Any help in fixing the output to get the tokenId directly would be a great help. There is limited help available on OpenAM. This has given me a couple of sleepless nights.
Method: POST
URL: http://localhost:8080/openam/json/authenticate?realm=/MYREALM
Headers:
1. Content-Type:application/json
2. X-OpenAM-Password:Wsdwe#9900
3. X-OpenAM-Username:sdf.er#dummy.com
Output on one server
{
"tokenId": "AQIC5wM2LY4SfcwB_yB8SZ5JOfJSzlbBCIb0645ky5NrwUY.*AAJTSQACMDMAAlNLADASMjExOTAwMjczNDI5Mjg0Mjc3MgACUzEAAjAy*",
"successUrl": "/openam/console"
}
Output on other server
{
"authId": "eyAidHlwIjogIkpXVCIsGHJhbGciOiAiSFMyNTYiIH0.eyAib3RrIjogImo1Y2gybnFqaGwybGhnZ250cWIzazNkMHFpIiwgInJlYWxtIjogIm89aXRzdXBwb3J0MjQ3ZGF0YXN0b3JlLG91PXNlcnZpY2VzLGRjPW9wZW5hbSxkYz1mb3JnAWEvY2ssZGM9b3JnIiwgInNlc3Npb25JZCI6ICJBUUlDNXdNMkxZNFNmY3h0UUDSFGlielFPYkJuUVUxTTNudUlab3JFdEcxX2liNC4qQUFKVFNRQUNNREVBQWxOTEFCTTRPRGcxTkRRME16STFNRFl3TXpnNE5EUTRBQUpUTVFBQSoiIH0.rWE7A_tjcsyiXpQdAXUsS6OiHi97HhXQEkYwY919ovE",
"template": "",
"stage": "IDMDataStore1",
"header": "Access Your Account",
"callbacks": [
{
"type": "NameCallback",
"output": [
{
"name": "prompt",
"value": "Email ID:"
}
],
"input": [
{
"name": "IDToken1",
"value": "sdf.er#dummy.com"
}
]
},
{
"type": "PasswordCallback",
"output": [
{
"name": "prompt",
"value": "Password:"
}
],
"input": [
{
"name": "IDToken2",
"value": ""
}
]
},
{
"type": "TextOutputCallback",
"output": [
{
"name": "message",
"value": "\n "
},
{
"name": "messageType",
"value": "0"
}
]
}
]
}
NOTE: I am using OpenAM 13.0.0

Resources