Metadata-Version: 2.4
Name: owa-graph
Version: 0.1.0
Summary: Pipe-friendly Microsoft Graph CLI - one-off Graph queries with owa-piggy auth
Author: Carl Joakim Damsleth
License: MIT License
        
        Copyright (c) 2026 damsleth
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/damsleth/owa-graph
Project-URL: Repository, https://github.com/damsleth/owa-graph
Project-URL: Issues, https://github.com/damsleth/owa-graph/issues
Project-URL: Changelog, https://github.com/damsleth/owa-graph/releases
Keywords: microsoft-graph,graph,microsoft-365,azure,cli,json,outlook
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: owa-piggy>=0.6.0
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# owa-graph

Pipe-friendly Microsoft Graph CLI. One-off Graph queries with `owa-piggy`
auth, no token plumbing, no `az login`, no app registration required.

```sh
owa-graph GET /me
owa-graph GET '/users?$top=5' --pretty
owa-graph GET /me/messages --top 10 --select id,subject,from
owa-graph POST /me/sendMail --body @mail.json
owa-graph PATCH /me/messages/AAMk... --body '{"isRead":true}'
owa-graph GET /me/drive/root/children --beta
owa-graph GET /me --curl | pbcopy
owa-graph GET me/events --audience outlook --pretty
```

## Install

```sh
brew install damsleth/tap/owa-piggy   # auth broker, required
pip install owa-graph                 # or: uvx owa-graph GET /me
```

## How it works

`owa-graph` is a thin verb-first wrapper around Microsoft Graph that
delegates auth to [`owa-piggy`](https://github.com/damsleth/owa-piggy):
on every call it shells out to `owa-piggy token --audience graph
--json`, takes the access token from stdout, and issues the HTTP
request with the right base URL and Bearer header.

- JSON on stdout, logs on stderr.
- `--pretty` prints tables for users / messages / drive items, indented
  JSON for everything else.
- `--curl` and `--az` print the equivalent shell command instead of
  executing - useful for sharing, scripting, or piping into `pbcopy`.
- `--beta` switches to `https://graph.microsoft.com/beta`.
- `--audience` retargets at any FOCI audience `owa-piggy` knows about
  (Outlook REST, Teams, Azure Mgmt, KeyVault, etc.) using the same
  query ergonomics.

## Auth

Default path: `owa-graph` shells out to `owa-piggy` for a fresh access
token on every call. `owa-piggy` owns the refresh token; `owa-graph`
stores only an optional profile alias and a default audience in
`~/.config/owa-graph/config`.

App-registration path (broader Graph scopes): set `GRAPH_APP_CLIENT_ID`,
`GRAPH_REFRESH_TOKEN`, and `GRAPH_TENANT_ID` and `owa-graph` will hit the
AAD token endpoint directly with `https://graph.microsoft.com/.default`
scope.

## Scope caveat

The OWA first-party SPA client `owa-piggy` borrows does NOT carry full
Graph permissions. Calls like `GET /me`, `/users`, `/me/joinedTeams`,
and most directory queries work; calendar/mail/files writes via Graph
return 403. Set `GRAPH_APP_CLIENT_ID` to your own app registration to
broaden scope, or use the audience-specific siblings (`owa-cal`,
`owa-mail`) which target the Outlook REST audience instead.

## Development

```sh
pip install -e '.[test]'
pytest -q
python -m compileall owa_graph
```

## License

MIT.
