How to write cURL requests to wso2 -


i trying connect wso2 api created using rest.

$userdata = array("username" => "user", "password" => "password"); $ch = curl_init("http://wso2.endpoint.com"); curl_setopt($ch, curlopt_customrequest, "post"); curl_setopt($ch, curlopt_postfields, json_encode($userdata)); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_httpheader, array("content-type: application/json","authorization: bearer concernpart", "content-lenght: " . strlen(json_encode($userdata))));  $token = json_decode(curl_exec($ch)); 

now not sure how write "authorization: bearer concernpart". need add statically in each request? how change in requests if change bearer token or regenerate it.

or there way can hit wso2 , bearer token , use in requests.

what need call token endpoint using preferred grant type , new access_token. can use access token actual api call. refer wso2 doc on how obtain access token


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -