Generation

generate functionTue, 23 May 2023

funcion para obtener el token de microsoft graph para enviar mail

import requests, json, time def get_token(): token_url = 'https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token' token_data = { 'client_id': '<client_id>', 'scope': 'https://graph.microsoft.com/.default', 'client_secret': '<client_secret>', 'grant_type': 'client_credentials' } token_request = requests.post(token_url, data=token_data) token = json.loads(token_request.text)['access_token'] return token

Questions about programming?Chat with your personal AI assistant