For your second question read this post from @Fox ,
maybe its what you need. Its in Russian, but you can
use translator. There is an example script too >
How do I get access token?
-
Please help how to POST like follow code in BAS (It''s ok in python):
import requests
email = "treezyjeckaz@hotmail.com"
password = "DgNroVonz"
refresh_token = "M.C517_BAY.0.U.-Ck!oX!QQd2TnqfUx5OetxvV2sfH3xt5nf50V!fYtWY0u0GXv0KxPZNMbEy22eJGBvgabrFaAIFtaTs82Q5yCctOqVR63hSR5AIB9PSqa9AxfIJ0DirIZ3L4ckH6aw3aLmFY4p9JSdr7CgJ8AsVWHwYF6KKq6zoWNwtywdzhOLyWQrpKZ!1rAz2rz2GAUINiMnHlK9vu967CeIMWRH7wSg3P!lNiee4Pgor5n1eC9SBL6WvVQaZJ6IeCRnjWoXzftR2pW!XoGu6QEF57H0J1KGSGbAAOVrDz3SLjrogjLOKYQt3ZL2nKD8MRpG7JB1e6yrxLb!q76mi62Fd4L9zlWkOJtruA6xtFh2OpEfeO!Q0aXDO8RXSKUalC*cpivFcd1aA!254YXU4XjMhM10lqOFsY4y725uGzH1WDQcnXjbPeY8j29FOj8MKbSTGng$$"
client_id = "8b4ba9dd-3ea5-4e5f-86f1-ddba2230dcf2"token_url = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
token_data = {
"grant_type": "refresh_token",
"refresh_token": refresh_token,
"client_id": client_id,
"scope": "https://graph.microsoft.com/.default"
}
headers = {
"Content-Type": "application/x-www-form-urlencoded" # Changed to x-www-form-urlencoded for this type of request
}
token_response = requests.post(token_url, data=token_data, headers=headers)if token_response.status_code == 200:
access_token = token_response.json().get("access_token")
print("Access Token:", access_token)