get_access_token.py 509 B

12345678910111213141516171819202122
  1. from nio import AsyncClient
  2. from configparser import ConfigParser
  3. async def main():
  4. config = ConfigParser()
  5. config.read("config.ini")
  6. user_id = input("User ID: ")
  7. password = input("Password: ")
  8. client = AsyncClient(config["Matrix"]["Homeserver"])
  9. client.user = user_id
  10. await client.login(password)
  11. print("Access token: " + client.access_token)
  12. await client.close()
  13. if __name__ == "__main__":
  14. import asyncio
  15. asyncio.get_event_loop().run_until_complete(main())