Skip to content

Instantly share code, notes, and snippets.

@bradymiller

bradymiller/client.php

Last active Jan 19, 2021
Embed
What would you like to do?
client.php for testing both online demo and local
<?php
/**
*
* Copyright MITRE 2012
*
* OpenIDConnectClient for PHP5
* Author: Michael Jett <mjett@mitre.org>
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
require __DIR__ . '/vendor/autoload.php';
use Jumbojett\OpenIDConnectClient;
$test = "not-local"; // local or not-local
$client_id = 'qG4hcWRYdsL2449IfOe1FJ5PSZ00QINaHLku9MXCOQE';
$client_secret = '5Yco4dUIEZfMudrX4aqONOzKeI34cTgtRS5NGWcu8OjH-DltMGGtUB4n3MFjm4e6fvyPq7MH0xn3OtRxfF9TUQ';
if ($test == "local") {
// localhost testing (2nd parameter is client id, 3rd parameter is client secret)
$oidc = new OpenIDConnectClient(
'https://localhost:9300/oauth2/default',
$client_id,
$client_secret
);
$oidc->setVerifyPeer(false);
$oidc->setVerifyHost(false);
} else {
// demo testing (2nd parameter is client id, 3rd parameter is client secret)
$oidc = new OpenIDConnectClient(
'https://eight.openemr.io/openemr/oauth2/default',
$client_id,
$client_secret
);
}
// includes patient scopes
//$oidc->addScope('api:oemr api:fhir api:port user/allergy.read user/allergy.write user/appointment.read user/appointment.write user/dental_issue.read user/dental_issue.write user/document.read user/document.write user/drug.read user/encounter.read user/encounter.write user/facility.read user/facility.write user/immunization.read user/insurance.read user/insurance.write user/insurance_company.read user/insurance_company.write user/insurance_type.read user/list.read user/medical_problem.read user/medical_problem.write user/medication.read user/medication.write user/message.write user/patient.read user/patient.write user/practitioner.read user/practitioner.write user/prescription.read user/procedure.read user/soap_note.read user/soap_note.write user/surgery.read user/surgery.write user/vital.read user/vital.write user/AllergyIntolerance.read user/CareTeam.read user/Condition.read user/Encounter.read user/Immunization.read user/Location.read user/Medication.read user/MedicationRequest.read user/Observation.read user/Organization.read user/Organization.write user/Patient.read user/Patient.write user/Practitioner.read user/Practitioner.write user/PractitionerRole.read user/Procedure.read patient/encounter.read patient/patient.read patient/AllergyIntolerance.read patient/Encounter.read patient/Patient.read');
// does not include patient scopes
$oidc->addScope('api:oemr api:fhir api:port api:pofh user/allergy.read user/allergy.write user/appointment.read user/appointment.write user/dental_issue.read user/dental_issue.write user/document.read user/document.write user/drug.read user/encounter.read user/encounter.write user/facility.read user/facility.write user/immunization.read user/insurance.read user/insurance.write user/insurance_company.read user/insurance_company.write user/insurance_type.read user/list.read user/medical_problem.read user/medical_problem.write user/medication.read user/medication.write user/message.write user/patient.read user/patient.write user/practitioner.read user/practitioner.write user/prescription.read user/procedure.read user/soap_note.read user/soap_note.write user/surgery.read user/surgery.write user/vital.read user/vital.write user/AllergyIntolerance.read user/CareTeam.read user/Condition.read user/Encounter.read user/Immunization.read user/Location.read user/Medication.read user/MedicationRequest.read user/Observation.read user/Organization.read user/Organization.write user/Patient.read user/Patient.write user/Practitioner.read user/Practitioner.write user/PractitionerRole.read user/Procedure.read');
$oidc->authenticate();
$id = $oidc->getIdToken();;
$access = $oidc->getAccessToken();
$refresh = $oidc->getRefreshToken();
?>
<html>
<head>
<title>Example OpenID Connect Client Use</title>
<style>
body {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<div>
ID: <?php echo $id; ?>
</div>
<div>
Access: <?php echo $access; ?>
</div>
<div>
Refresh: <?php echo $refresh; ?>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment