I never used auth0 I want to implement in my rest API's, I created an account and I have client's id
, secret
and get my access_token
. So now I want to know that how can I use in multiple API's? Here is my code for one of the API, I have to write code again and again for all API's? or there is another way?
Here is my code
curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://path_to_your_api/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}