Migrosoft Teams mgraph REQUEST 401 SSL errror

26 Views Asked by At

I encountered an error while importing microsoft teams data with precenesURL. I shared the URL information, python code and the error I encountered below. But,I don't get any error while retrieving UserDF info. I dont understand what was happened suddenly this code always works ,properly. As I said , i can visualize UsersDF dataframe there is no mistake but presencesURL get error

appId = 'xyz-bf9b-48c0-bafb-xyz89139f197' clientSecret = '_az*************=' tokenUrl = 'https://login.microsoftonline.com/xyz-1f64-4360-abc-601b4bb1b236/oauth2/token' usersUrl = 'https://graph.microsoft.com/v1.0/users?$top=999' presencesUrl = 'https://graph.microsoft.com/v1.0/communications/getPresencesByUserId' tokenData = { 'grant_type': 'password', 'client_id': appId, 'client_secret': clientSecret, 'resource': 'https://graph.microsoft.com', 'scope':'https://graph.microsoft.com', 'username':'[email protected]', 'password':'abc2020!', }

tokenReq = requests.post(tokenUrl, data=tokenData) token = tokenReq.json().get('access_token') usersDF = pd.DataFrame() userPresenceDF = pd.DataFrame() nRow = 100

for i in range(math.ceil(len(usersDF)/nRow)):

reqIds = '","'.join(str(i) for i in usersDF.iloc[i * 100:(i + 1) * 100,]['id'])
reqBody = '''{
"ids": ["''' + reqIds + '''"]
}'''

presencesReq= requests.post(presencesUrl, headers = {'Authorization': '{}'.format(token)}, json=json.loads(reqBody))

print(presencesReq)

Request[401] Error

0

There are 0 best solutions below