Skip to content

Instantly share code, notes, and snippets.

@AnishDe12020
Created May 25, 2021 10:15
Show Gist options
  • Save AnishDe12020/eebb22369899e0f41ffebe8beb710337 to your computer and use it in GitHub Desktop.
Save AnishDe12020/eebb22369899e0f41ffebe8beb710337 to your computer and use it in GitHub Desktop.
Issue with the code, gives an error after successful authentication
from configparser import ConfigParser
def config():
config = ConfigParser()
config.add_section("graph_api")
config.set("graph_api", "client_id", "<CLIENT_ID>")
config.set("graph_api", "client_secret", "<CLIENT_SECRET>")
config.set("graph_api", "redirect_uri", "https://localhost/graph_login")
with open(file="configs/config.ini", mode="w+") as config_file:
config.write(config_file)
from configurator import config
from configparser import ConfigParser
from ms_graph.client import MicrosoftGraphClient
config()
config = ConfigParser()
config.read("configs/config.ini")
scopes = [
"files.read"
]
creds_file = "configs/ms_graph_state.jsonc"
client_id = config.get("graph_api", "client_id")
client_secret = config.get("graph_api", "client_secret")
redirect_uri = config.get("graph_api", "redirect_uri")
graph_client = MicrosoftGraphClient(
client_id = client_id,
client_secret = client_secret,
redirect_uri = redirect_uri,
scope = scopes,
credentials = creds_file
)
graph_client.login()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment