Skip to content

Python tool to fetch MS Teams status from GraphAPI.

License

Notifications You must be signed in to change notification settings

youseeus/teamsPresenceBridge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Teams Presence Bridge

Python tool to fetch MS Teams status from GraphAPI and present it as RestApi.

1. Setup Azure app

1.1 Login with your company MS account and Register a new app here: Azure Portal

1.2 Give your app a name, set supported account types to: Only accounts in this organizational directory and the redirect URL to: https://login.microsoftonline.com/common/oauth2/nativeclient

1.3 Copy and store the applicationId and the tennantId from the dashboard, you need those later!

1.4 In the left sidebar, go to Certificates & secrets. Then, create a new secret clientkey. Copy and store the clientkey, not the Id!

1.5 In the left sidebar, go to "API-Rights", than "Add-Rights". Choose "Microsoft Graph" and "Delegated rights". Search and tick "offline_access" and "Presence.read".

2. Setup teamsPresenceBridge

There are several ways to install this. You can use it locally, as Home assistant Add-On or as docker container.

a. Local install

2.1 Clone repository git clone https://github.com/Dielee/teamsPresenceBridge.git

2.2 Install requirements with pip3 install -r requirements.txt

2.3 Fill src/config.yaml with your azure data from step one.

2.4 Run the application from src directory with python on windows or linux with: python3 .\server.py

2.5 Authenticate your application with graph api. Open your browser and go to http://ipApplicationRunsAt:5557/getRequestURL. If everything has been configured correctly, you will now be asked whether the app should be authorized. Select "Yes" and then copy the forwarded URL in the browser. Next, go to http://ipApplicationRunsAt:5557/getToken?url=yourRequestURL and paste the copied request URL from /getRequestURL.
Now, you should see an Authentication successful, token stored!. If not, try again from step one and check all keys and tokens.

2.6 If everything worked, you can fetch your presence state with http://ipApplicationRunsAt:5557/getPresence

b. Home assistant install

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

Use the button above or add the URL of this repository to add it manually. Or follow the steps at the HomeAssistant docs

c. Docker install

2.1 Pull container docker pull dielee/teamspresencebridge:latest

2.2 Start container docker run -d -p 5557:5557 -e azureApplicationId="applicationId" -e azureClientKey="<clientKey>" -e azureTenantId="<tenantId>" teamspresencebridge:latest

2.3 Authenticate your application with graph api. Open your browser and go to http://dockerIp:5557/getRequestURL. If everything has been configured correctly, you will now be asked whether the app should be authorized. Select "Yes" and then copy the forwarded URL in the browser. Next, go to http://dockerIp:5557/getToken?url=yourRequestURL and paste the copied request URL from /getRequestURL.
Now, you should see an Authentication successful, token stored!. If not, try again from step one and check all keys and tokens.

2.4 If everything worked, you can fetch your presence state with http://dockerIp:5557/getPresence

3. Setup Teams host state (optional)

If you want to monitor not only the teams status, but also the status of the pc running teams, you can report every four minutes to the teamspresencebridge that the pc is still online. You can do this using the examples in the setTeamsHostOnline folder.

4. Troubleshooting

AADSTS700025: Client is public so neither 'client_assertion' nor 'client_secret' should be presented.

if you get an Authentication error and in the server logs an AADSTS700025: Client is public so neither 'client_assertion' nor 'client_secret' should be presented. check in the Azure Portal -> Authentication the platform shoud be web and the toggle Allow public client flows is on no

About

Python tool to fetch MS Teams status from GraphAPI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 89.1%
  • Dockerfile 7.8%
  • PowerShell 1.8%
  • Shell 1.3%