I am trying to integrate AWS Cognito as an authentication service for Shopify users. I used miniOrange service as an identity broker between Cognito and Shopify by sharing the client id and client secret and Amazon Cognito domain. Currently it's working perfect with Cognito hosted UI, but I want to use my own UI and logic while maintaining this connection between Shopify and Cognito. What I done so far is that I am using Cognito domain to and I am calling in nodejs :
{AUTH_DOMAIN}/oauth2/authorize?response_type=${RESPONSE_TYPE}&client_id=${CLIENT_ID}&redirect_uri=${REDIRECT_URI}&scope=${SCOPE}
which will give me the csrf in a cookie header, which will be used in the second api call along with the username and password:
const form = {
_csrf: `${XSRFTOKEN.split(";")[0].split("=")[1]}`,
username: `${USERNAME}`,
password: `${PASSWORD}`,
};
var formData = querystring.stringify(form);
var contentLength = formData.length;
request(
{
headers: {
"Content-Length": contentLength,
"Content-Type": "application/x-www-form-urlencoded",
Cookie: `${XSRFTOKEN}`,
},
uri:https://${AUTH_DOMAIN}/loginresponse_type=${RESPONSE_TYPE}&client_id=${CLIENT_ID}&redirect_uri=${REDIRECT_URI},
body: formData,
method: "POST",
}
this will give me the authorization code which will then I am redirecting to the redirect URL with the code as a param, but it's failing to open Shopify , there is something missing I can't figure out
any help?