Hi there I am using replit to write a telegram bot that updates the user input to a excel file. I connected ms graph api to my code. It didn't worked I mean worked but the excel file wasn't updated. So I tried getting the access token which was a success and then implemented that code the error wasn't resolved so I tried connecting it through the manual authorization process the login screen to permit the access token it showed another eror then I came over this..
No matter what I am trying whateber I am adding in the azure portal the link remains the same. My get access token function
import logging
import msal
from hi import CLIENT_ID, TENANT_ID
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("main")
SCOPES = ["https://graph.microsoft.com/.default"]
def get_access_token():
authority = f"https://login.microsoftonline.com/{TENANT_ID}"
app = msal.PublicClientApplication(CLIENT_ID, authority=authority)
try:
result = app.acquire_token_interactive(scopes=SCOPES)
access_token = result.get('access_token')
if access_token:
return access_token
else:
error_msg = result.get('error_description', result.get('error', 'Unknown error'))
logger.error(f"Failed to retrieve access token: {error_msg}")
raise Exception(f"Could not retrieve access token: {error_msg}")
except Exception as e:
logger.error(f"Exception while retrieving access token: {str(e)}")
raise
# Example usage:
try:
token = get_access_token()
print("Access token:", token)
except Exception as e:
print("Error:", str(e))

My Images of at the azure portal are


