By Gueu PACOME
Hello i have the following credential I would like to use them for authentification and fetch the token from header using PHP.
GRAND TYPE: client_redential (json) TOKEN URL: http://localhost/?access-token CLIENT ID: 5646545-4654651-45645465-554 CLIENT SECRET: 874561-565156-5646551
Can someone helps me ?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
To receive an access token, the client POSTs an API call to Edge with the values for client ID and client secret obtained from a registered developer app. In addition, the parameter grant_type=client_credentials must be passed as a query parameter.
@pistle2020 Hello, thank you for your answer: The Body to send is a jSon format:
{
"grant_type": "client_credentials"
}
I use Insomnia to generate this PHP cURL Script Here is my PHP cURL script:
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://localhost/access-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n\t\"grant_type\": \"client_credentials\"\n}",
CURLOPT_COOKIE => "dtCookie=v_4_srv_2_sn_6BC691EA47E4B3612884E99AB3D8EB3B_perc_100000_ol_0_mul_1",
CURLOPT_HTTPHEADER => [
"authorization: Bearer 55d4f5s5-dff4-56dsf54-dsdfsdf",
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
###########################
The result of this sccript is:
{
"message": "Invalid Authorization header"
}
But i can see in the Insomnia GUI the generates Token. My Problem is, how to get the token in variable a use it.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
