import requests
AUTH_ENDPOINT = (
"https://auth.longenesis.com/realms/curator-engage/protocol/openid-connect/token"
)
USERNAME = "<your username>"
PASSWORD = "<your password>"
CLIENT_ID = "<Longenesis issued client id>"
CLIENT_SECRET = "<Longenesis issued client id>"
ORG_SLUG = "<your organisation slug>"
PROJECT_SLUG = "<your project slug>"
ENGAGE_ACTIVITY_SLUG = "<activity SLUG>"
REDIRECT_URL = (
"https://engage.longenesis.com/en/{ORG_SLUG}/project/{PROJECT_SLUG}/{ENGAGE_ACTIVITY_SLUG}?authCode={code}"
)
access_token = requests.post(
AUTH_ENDPOINT,
data={
"username": USERNAME,
"password": PASSWORD,
"grant_type": "password",
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
},
).json()["access_token"]
PERSON_DATA = {
"participant_id": "0000099",
"participant_full_name": "John Doe",
"guardian_id": "0007",
"guardian_full_name": "Jane Doe",
"free_text": ["Hello John!"],
}
response = requests.post(
f"https://engage-openapi.longenesis.com/get_auth_code",
json=PERSON_DATA,
headers={"Authorization": f"Bearer {access_token}"},
)
print(
REDIRECT_URL.format(
slug=ENGAGE_ACTIVITY_SLUG, code=response.json()["authorization_code"]
)
)
https://engage.longenesis.com/en/{ORG_SLUG}/project/{PROJECT_SLUG}/{ENGAGE_ACTIVITY_SLUG}?authCode=A2DA055ED45F4FBE806EAD5B3B937F00
<iframe
src="https://engage.longenesis.com/en/sunshinehospital/project/aabbcc/ddeeff?authCode=AABBCCDDEEFF001122"
width="100%"
height="1200"
style="border:none;"></iframe>
<iframe
id="iframe-id"
src="https://engage.longenesis.com/en/sunshinehospital/project/aabbcc/ddeeff?authCode=AABBCCDDEEFF001122"
width="100%"
style="border: none;"
scrolling="no"></iframe>
function handleIframeMessage(event) {
const iframe = document.getElementById('iframe-id');
if (event.data.type === 'setHeight') {
iframe.style.height = event.data.height + 'px';
if (event.data.scrollToTop) {
window.scrollTo(0, 0);
}
}
}
window.addEventListener('message', handleIframeMessage);
{
"person_id": "same_as_participant_id",
"org_level": ["perm1", "perm2", ...],
"projects": {
"project_slug1": ["perm1", "perm2", ...],
"project_slug2": ["perm1", ...]
}
}