I am developing an OpenId integration from php and I have to send a jwt token to an endpoint.
I use Jwt firebase to generate and validate the jwt:
$key = 'xxxx';
$data = array(
"tenantId" => self::TENANT_ID,
"clientId" => self::CLIENT_ID,
"objectId" => $oid,
"iss" => "issuer",
"aud" => "audience",
"exp" => 1474980478,
"nbf" => 1474976878,
"state" => $state,
"message" => $msg,
"notifierAppID" => self::B2C_ID
);
$jwt = JWT::encode(
$data,
$key,
'HS256'
);
The structure of the Endpoint is something like:
https://dominio/{prametro}/app/{parametro}/estado
The idea is that I have to send the token I generate for uqe to return data about an object.
Once the jwt is generated, how can I send the jwt to the endpoint from PHP?
I'm trying with this code, but it does not seem to work:
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>
"Authorization: bearer ".$jwt
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$result = file_get_contents($endpoint, false, $context);