Skip to content

Instantly share code, notes, and snippets.

View kellerza's full-sized avatar

Johann Kellerman kellerza

View GitHub Profile
@kellerza
kellerza / msal_async.py
Last active March 27, 2024 16:32
AsyncIO based OAuth Authorization Code Flow using the Microsoft MSAL Python library. Includes an aiohttp server example.
"""AsyncIO based OAuth Authorization Code Flow using the Microsoft MSAL Python library.
The AsyncMSAL class contains more info to perform OAuth & get the required tokens.
Once you have the OAuth tokens store in the session, you are free to make requests
(typically from an aiohttp server's inside a request)
For more info on Authorization Code flow, refer to https://auth0.com/docs/flows/authorization-code-flow
"""
import asyncio
import json
@kellerza
kellerza / oauth2_session.py
Last active March 23, 2023 10:39
OAuth2 authentication with aiohttp and oauthlib (based on requests_oauthlib)
"""OAuth2Support for aiohttp.ClientSession.
Based on the requests_oauthlib class
https://github.com/requests/requests-oauthlib/blob/master/requests_oauthlib/oauth2_session.py
"""
# pylint: disable=line-too-long,bad-continuation
import logging
from oauthlib.common import generate_token, urldecode
from oauthlib.oauth2 import WebApplicationClient, InsecureTransportError
#!/usr/bin/env python3
# pylint: disable=invalid-name
"""mbox-extract-attachments3 - Extract attachments from mbox files.
Good companion for Google Takeout https://takeout.google.com/settings/takeout
Modified by http://github.com/kellerza from
https://github.com/PabloCastellano/pablog-scripts/
- Python3 & linter errors
- New Filenames
@kellerza
kellerza / qsusb_decode.py
Created May 23, 2016 18:35
Decode QSUSB 'val' attributes
"""Testing QwikSwitch value attributes."""
def legacy_status(st):
"""legacy_status method from the qsmobile.js.
Pass in the 'val' from &devices or the
'data' received after calling a specific ID.
"""
# 2d0c00002a0000
@kellerza
kellerza / qsusb_autostart.md
Created May 17, 2016 17:06
QS Mobile auto-start instructions

Qwikswitch Mobile auto-start

This gist contains instructions to auto-start the QS Mobile application (used for Debain/Jesse on Raspberry Pi).

  • Create a 'qsusb' user: sudo adduser qsusb

  • Copy the QS Mobile application to /home/qsusb/qsusb

  • Ensure all the files belong to the target user:

    sudo chown qsusb:qsusb -R /home/qsusb/qsusb/*