Cannot get access token after getting SAML assertion

Hi team,

I got SAML assertion from Microsoft AD but I am passing it to get access token and its throwing me "invalid request" error.

nodejs code:

app.post('/saml', function (req, res) {
console.log("reponse from Azure AD", req.body);
var assertion = req.body.SAMLResponse;
console.log("assertion from AD", assertion);
var encodedData = new Buffer.from(process.env.GENESYS_CLOUD_CLIENT_ID + ':' + process.env.GENESYS_CLOUD_CLIENT_SECRET).toString('base64');

let config = {
    method: "post",
    url: 'https://login.mypurecloud.com/oauth/token',
    host: 'http://localhost:1363/',
    headers: {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": 'Basic ' + encodedData
    },
    'body': {
        'grant_type': 'urn:ietf:params:oauth:grant-type:saml2-bearer',
        'orgName': 'hexawaretechnologieslimited',
        'assertion': assertion

    },
    'mode': 'cors',
}

axios(config)
    .then(function (response) {
        //handle success
        console.log("response from Genesys token--------", response);
    })
    .catch(function (response) {
        //handle error
        console.log(response);
    });

can you please tell what is wrong with above reqiest.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.