Hello i have the following credential
I would like to use them for authentification and fetch the token from header using PHP.

Credential

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 ?

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.

×
2 answers

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 granttype=clientcredentials 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.

edited by MattIPv4
Submit an Answer