Last active
October 18, 2024 23:55
-
-
Save petergs/52c4318925d4064586b8c68a598872da to your computer and use it in GitHub Desktop.
graph-api-token-from-stdin-template.py
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 | |
| import sys | |
| import json | |
| MS_GRAPH_API_BASE_URL = "https://graph.microsoft.com" | |
| if __name__ == "__main__": | |
| if sys.stdin is not None: | |
| access_token = sys.stdin.readline().rstrip() | |
| else: | |
| print("Error: Expecting an access_token supplied from stdin") | |
| sys.exit(1) | |
| headers = { | |
| "Authorization": f"Bearer {access_token}", | |
| "Content-Type": "application/json", | |
| } | |
| r = requests.get( | |
| url=f"{MS_GRAPH_API_BASE_URL}/v1.0/me", | |
| headers=headers, | |
| ).json() | |
| print(json.dumps(r, indent=2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment