Skip to content

Commit

Permalink
Add connect2 request
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepdeJong committed Jul 27, 2023
1 parent 689b257 commit 3514e99
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/plugins/authiapconnect2/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,33 @@ private function getIapToken()
*/
private function getUserDataFromToken($token)
{
//
// Get request to Connect2
$url = $this->getConf('connect2_endpoint');

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-Goog-IAP-JWT-Assertion: ' . $token
),
));

$response = curl_exec($curl);

curl_close($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ($httpcode != 200) {
throw new Exception('Could not get user data');
}

return json_decode($response, true);
}
Expand Down

0 comments on commit 3514e99

Please sign in to comment.