awacke1 commited on
Commit
3d9aeea
·
verified ·
1 Parent(s): 9c7ea38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import msal
2
  import os
3
  import streamlit as st
4
- import webbrowser
5
 
6
 
7
  from msal import PublicClientApplication
@@ -25,16 +25,18 @@ client_instance = msal.ConfidentialClientApplication(
25
 
26
  authorization_request_url = client_instance.get_authorization_request_url(SCOPES)
27
  st.write('Connecting to MSGraph with url:' + authorization_request_url)
28
- webbrowser.open(authorization_request_url, new=True)
29
 
30
- authorization_code = '' #Get from url of webbrowser response - this is contingent on the URL set in MS Graph API Authentication section
 
 
31
 
32
-
33
- #access_token_id = access_token['access_token']
34
- #headers = {'Authorization': 'Bearer ' + access_token_id}
35
-
36
- #endpoint = base_url + 'me'
37
- #response = requests.get()
38
 
39
  # URLs used in this sample app to demonstrate MS Graph in Python
40
  # https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/~/Authentication/appId/d36c689d-3c61-4be6-a230-c09fc54cf80d/objectId/ece93996-1d7c-4b39-abc5-de51487073ed/isMSAApp~/false/defaultBlade/Overview/appSignInAudience/AzureADandPersonalMicrosoftAccount/servicePrincipalCreated~/true
 
1
  import msal
2
  import os
3
  import streamlit as st
4
+ import webbrowser as wb
5
 
6
 
7
  from msal import PublicClientApplication
 
25
 
26
  authorization_request_url = client_instance.get_authorization_request_url(SCOPES)
27
  st.write('Connecting to MSGraph with url:' + authorization_request_url)
28
+ wb.open(authorization_request_url, new=True)
29
 
30
+ access_token = client.instance.acquire_token_by_authorization_code(
31
+ code=AUTHORIZATION_KEY,
32
+ scopes=SCOPES)
33
 
34
+ access_token_id = access_token['access_token']
35
+ headers = {'Authorization': 'Bearer ' + access_token_id}
36
+ endpoint = base_url + 'me'
37
+ response = requests.get(endpoint, headers=headers)
38
+ st.write(response)
39
+ st.write(rresponse.json)
40
 
41
  # URLs used in this sample app to demonstrate MS Graph in Python
42
  # https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/~/Authentication/appId/d36c689d-3c61-4be6-a230-c09fc54cf80d/objectId/ece93996-1d7c-4b39-abc5-de51487073ed/isMSAApp~/false/defaultBlade/Overview/appSignInAudience/AzureADandPersonalMicrosoftAccount/servicePrincipalCreated~/true