Metadata-Version: 2.1
Name: elytra-ms
Version: 0.1.1
Summary: A Python Library for various Microsoft APIs, including the Xbox and Bedrock Realms APIs.
Project-URL: Homepage, https://github.com/AstreaTSS/elytra-ms
Author: AstreaTSS
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: aiohttp
Requires-Dist: aiohttp-retry
Requires-Dist: msgspec
Requires-Dist: typing-extensions
Provides-Extra: orjson
Requires-Dist: orjson; extra == 'orjson'
Description-Content-Type: text/markdown

# elytra-ms
A Python Library for various Microsoft APIs, including the Xbox and Bedrock Realms APIs.

**Note: this library is a work in progress!** This currently only supports the workflow [the Realms Playerlist Bot](https://github.com/AstreaTSS/RealmsPlayerlistBot) does, but it is planned to be expanded in the future.

## Usage

```python
import asyncio
import elytra

async def main():
    xbox_api = await elytra.XboxAPI.from_file("CLIENT_ID", "CLIENT_SECRET", oauth_path="oauth.json")
    print(await xbox_api.fetch_profile_by_gamertag("SomeGamertag"))
    await xbox_api.close()

asyncio.run(main())
```

## Setup

TODO: actually do this section.

### Install Package

Requires Python 3.10+.

```sh
pip install -U elytra-ms
```

### Make An Application

> Taken from [xbox-webapi-python](https://github.com/OpenXbox/xbox-webapi-python) for now, copyright 2020 OpenXbox under MIT.

Authentication is supported via OAuth2.

- Register a new application in [Azure AD](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade).
  - Name your app.
  - Select "Personal Microsoft accounts only" under supported account types.
  - Add <http://localhost/auth/callback> as a Redirect URI of type "Web."
- Copy your Application (client) ID for later use.
- On the App Page, navigate to "Certificates & secrets."
  - Generate a new client secret and save for later use.

### Get OAuth/Token Data

In your terminal, run:

```sh
elytra-authenticate --client-id CLIENT_ID_FROM_ABOVE --client-secret CLIENT_SECRET_FROM_ABOVE
```

This will create a file called `oauth.json` in the directory this is run in. This file alone works with all APIs currently supported.