Hi guys!, i’m having an issue when trying to authenticate with the xibo API, im performing an angulajs http post to /api/authenticate/access_token , passing client_id , client_secret, and grant_type with content-type header as application/x-www-form-urlencoded to prevent the OPTIONS request, but it gives me a 400 bad request error with this message
$http.post('url+/api/authorize/access_token',{
grant_type:"client_credentials",
client_id:"DQGcOyXE3GeUnyyMdMbnNAW8GwZDCGe2keN3iUo5", client_secret:"RL2SDzLm0byXlUcpAaKyNLo60bl3Ft8Yr8tZinEibr5GeAYUI4Y1tbkT71bG3oH3cWF9Z6LsCWyO69qk59jKxqwFghzy8LdRZxtUgOqMkoVrxBkPIXCmRSsVPH8W7JkP0Zkrlw72GbgoMeEK7sqNTSg4NtIyid6chk9uApyEXXEVKIvnIentZWPETbyGT3GbmkT8CxQ0cnluEqD97UY5vsNvX6c5KmnmcBw8Th8hqEi1hcmXyhrMyuceqVJgnr",
},{headers:{'Content-Type':'application/x-www-form-urlencoded'}});
{
"error": {
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the \"grant_type\" parameter.",
"code": 400,
"data": []
}
}
as you can see it’s saying that the grant type parameter is missing or wrong, but…it is present in the payload ( checking with console mode ) … so … anyone has a clue? Thanks in advance…
Hi Peter, the {headers:{‘Content-Type’:‘application/x-www-form-urlencoded’}} or {headers:{‘Content-Type’:‘text/plain’}} is being added to avoid the preflight OPTIONS request that returns a 404 if I remove the header,and indeed, from postman or performing a jQuery ajax its working well… but performing an XMLHttpRequest from angular doesn’t seems to be working as expected… so im hitting my head against the wall to get this thing working… any other idea?