Last active
June 5, 2021 12:19
-
-
Save jbaiter/029a1bd9578aeac61d5a59d3d566f177 to your computer and use it in GitHub Desktop.
Check if a a COVID-19 vaccination appointment can be made, for Bavarian citizens.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from keycloak import KeycloakOpenID | |
# To obtain this, log into your account and select a person. | |
# The citizen ID is the last part of the URL, a UUID | |
CITIZEN_ID = None | |
# This is your authentication info | |
EMAIL = None | |
PASSWORD = None | |
keycloak_openid = KeycloakOpenID( | |
server_url='https://ciam.impfzentren.bayern/auth/', | |
client_id='c19v-frontend', realm_name='C19V-Citizen') | |
token = keycloak_openid.token(EMAIL, PASSWORD) | |
resp = requests.get( | |
f'https://impfzentren.bayern/api/v1/citizens/{CITIZEN_ID}/appointments/next', | |
params={ 'timeOfDay': 'ALL_DAY' }, | |
headers={ 'Authorization': f'Bearer {token["access_token"]}' }) | |
if resp.status_code == 200: | |
# Congratulations, you can now select an appointment in the app! | |
appointment_candidate = resp.json() | |
# Go nuts! Send a message, ring a bell, notify your IoT devices, whatever comes to mind | |
else: | |
# The API returns 404 if there are no appointments available for selection | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment