azauthlib 1.0.0b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- azauthlib-1.0.0b1/PKG-INFO +248 -0
- azauthlib-1.0.0b1/README.md +225 -0
- azauthlib-1.0.0b1/azauthlib/__init__.py +23 -0
- azauthlib-1.0.0b1/azauthlib/_configure.py +240 -0
- azauthlib-1.0.0b1/azauthlib/_def.py +2 -0
- azauthlib-1.0.0b1/azauthlib/appdata.py +359 -0
- azauthlib-1.0.0b1/azauthlib/assets/gui_main.png +0 -0
- azauthlib-1.0.0b1/azauthlib/authentication.py +637 -0
- azauthlib-1.0.0b1/azauthlib/config_app.py +291 -0
- azauthlib-1.0.0b1/azauthlib/gui_utils.py +44 -0
- azauthlib-1.0.0b1/azauthlib/permissions.py +111 -0
- azauthlib-1.0.0b1/azauthlib/tokens.py +96 -0
- azauthlib-1.0.0b1/azauthlib.egg-info/PKG-INFO +248 -0
- azauthlib-1.0.0b1/azauthlib.egg-info/SOURCES.txt +18 -0
- azauthlib-1.0.0b1/azauthlib.egg-info/dependency_links.txt +1 -0
- azauthlib-1.0.0b1/azauthlib.egg-info/entry_points.txt +2 -0
- azauthlib-1.0.0b1/azauthlib.egg-info/requires.txt +3 -0
- azauthlib-1.0.0b1/azauthlib.egg-info/top_level.txt +1 -0
- azauthlib-1.0.0b1/setup.cfg +4 -0
- azauthlib-1.0.0b1/setup.py +47 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: azauthlib
|
|
3
|
+
Version: 1.0.0b1
|
|
4
|
+
Summary: A Python library simplifying Azure Microsoft Graph authentication. Provides an intuitive interface for acquiring access tokens through interactive login, silent authentication, device code flow, and client credentials flow. Includes utilities for seamless token storage and refresh management.
|
|
5
|
+
Home-page: https://github.com/cedricmoorejr/azauthlib/tree/v1.0.0b1
|
|
6
|
+
Author: Cedric Moore Jr.
|
|
7
|
+
Author-email: cedricmoorejunior5@gmail.com
|
|
8
|
+
License: Apache Software License
|
|
9
|
+
Project-URL: Source Code, https://github.com/cedricmoorejr/azauthlib/releases/tag/v1.0.0-beta.1
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Natural Language :: English
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Requires-Python: >=3.7
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
<div align="center">
|
|
29
|
+
|
|
30
|
+
# π **azauthlib** π
|
|
31
|
+
|
|
32
|
+
> **Your Simplified Authentication Companion for Azure Microsoft Graph**
|
|
33
|
+
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
`azauthlib` is a Python library that **streamlines the authentication process** with Azure Microsoft Graph. From interactive logins to client credentials flow, `azauthlib` provides an intuitive interface, robust token management, and a GUI for seamless configuration.
|
|
38
|
+
|
|
39
|
+
π Whether you're building applications that interact with Microsoft Graph APIs or automating workflows, `azauthlib` has you covered.
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+

|
|
43
|
+

|
|
44
|
+

|
|
45
|
+

|
|
46
|
+

|
|
47
|
+

|
|
48
|
+

|
|
49
|
+

|
|
50
|
+

|
|
51
|
+

|
|
52
|
+

|
|
53
|
+

|
|
54
|
+

|
|
55
|
+

|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## β¨ **Features** β¨
|
|
59
|
+
|
|
60
|
+
β
**Multiple Authentication Flows**
|
|
61
|
+
- Silent Authentication
|
|
62
|
+
- Interactive Authentication
|
|
63
|
+
- Device Code Flow
|
|
64
|
+
- Client Credentials
|
|
65
|
+
|
|
66
|
+
β
**Graphical User Interface (GUI)**
|
|
67
|
+
- Configure credentials with an easy-to-use GUI.
|
|
68
|
+
|
|
69
|
+
β
**Token Management**
|
|
70
|
+
- Automatic refresh for access tokens
|
|
71
|
+
- Secure token storage
|
|
72
|
+
|
|
73
|
+
β
**Flexible Environment Configuration**
|
|
74
|
+
- Use `.env` files, OS variables, or direct input.
|
|
75
|
+
|
|
76
|
+
β
**Customizable Permissions**
|
|
77
|
+
- Specify Microsoft Graph API scopes effortlessly.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## π **Installation**
|
|
82
|
+
|
|
83
|
+
### Install from PyPI
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install azauthlib
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Install from Source
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
git clone https://github.com/cedricmoorejr/azauthlib.git
|
|
93
|
+
cd azauthlib
|
|
94
|
+
pip install .
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### π **Requirements**
|
|
98
|
+
- Python 3.7+
|
|
99
|
+
- `msal`
|
|
100
|
+
- `portalocker`
|
|
101
|
+
- `python-dotenv`
|
|
102
|
+
|
|
103
|
+
Install dependencies manually if needed:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pip install -r requirements.txt
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## π **Getting Started**
|
|
112
|
+
|
|
113
|
+
### 1οΈβ£ **Prerequisites**
|
|
114
|
+
- Register an app in **Azure Active Directory** via the [Azure Portal](https://portal.azure.com/).
|
|
115
|
+
- Collect the following:
|
|
116
|
+
- `CLIENT_ID`
|
|
117
|
+
- `TENANT_ID`
|
|
118
|
+
- (Optional) `CLIENT_SECRET`
|
|
119
|
+
|
|
120
|
+
- Assign the appropriate Microsoft Graph API permissions.
|
|
121
|
+
|
|
122
|
+
### 2οΈβ£ **Configuration Options**
|
|
123
|
+
#### π **Option A: GUI Mode**
|
|
124
|
+
|
|
125
|
+
Launch the GUI for intuitive configuration:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
python config_app.py
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> π‘ **What You Can Do in the GUI:**
|
|
132
|
+
> - Enter credentials (`CLIENT_ID`, `TENANT_ID`, etc.).
|
|
133
|
+
> - Choose your authentication method.
|
|
134
|
+
> - Credentials are saved securely in a `.env` file.
|
|
135
|
+
|
|
136
|
+

|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
#### π **Option B: Non-GUI Mode**
|
|
141
|
+
|
|
142
|
+
1. **Using Environment Variables** (Recommended):
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
export TENANT_ID="your-tenant-id"
|
|
146
|
+
export CLIENT_ID="your-client-id"
|
|
147
|
+
export CLIENT_SECRET="your-client-secret"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
2. **Hardcoding in Code** (β οΈ Not Recommended):
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from azauthlib import Authentication
|
|
154
|
+
|
|
155
|
+
auth = Authentication(scopes="Files.ReadWrite.All")
|
|
156
|
+
auth.Build.WithEntry(
|
|
157
|
+
client_id="your-client-id",
|
|
158
|
+
tenant_id="your-tenant-id",
|
|
159
|
+
client_secret="your-client-secret"
|
|
160
|
+
)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## π **Authentication Flows**
|
|
166
|
+
|
|
167
|
+
### π **Silent Authentication**
|
|
168
|
+
Authenticate using cached tokens.
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
auth.Silent()
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### π **Interactive Authentication**
|
|
175
|
+
Prompts user to log in via a browser.
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
auth.Interactive()
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### π± **Device Code Flow**
|
|
182
|
+
Displays a device code for cross-device authentication.
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
auth.DeviceCodeFlow(webbrowser_enabled=True)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### π€ **Client Credentials Flow**
|
|
189
|
+
Authenticate server-to-server.
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
auth.ClientCredentials()
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## πΌ **Token Management**
|
|
198
|
+
|
|
199
|
+
- **Access Token**: Retrieve the active token.
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
token = auth.access_token
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
- **Token Expiry**: Check token lifetime.
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
print("Token expires in:", auth.token_expires_in)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
- **Automatic Refresh**: Tokens are refreshed seamlessly.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## π **Logging**
|
|
216
|
+
|
|
217
|
+
Easily track authentication flow and token operations using Pythonβs `logging` module. Customize as needed!
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## π€ **Contributing**
|
|
222
|
+
|
|
223
|
+
We welcome contributions! π Here's how you can help:
|
|
224
|
+
1. Fork the repo.
|
|
225
|
+
2. Create a feature or bugfix branch.
|
|
226
|
+
3. Submit a PR with a detailed description.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## π **License**
|
|
231
|
+
|
|
232
|
+
This project is licensed under the **Apache License 2.0**. See the `LICENSE` file for more details.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## βΉοΈ **Trademarks**
|
|
237
|
+
|
|
238
|
+
- This project references **Microsoft** trademarks such as Azure and Microsoft Graph. Please ensure compliance with Microsoftβs [Trademark Guidelines](https://www.microsoft.com/trademarks).
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
π **[GitHub Repository](https://github.com/cedricmoorejr/azauthlib/tree/v1.0.0b1)**
|
|
243
|
+
π¬ **Feedback? Issues?** Weβd love to hear from you!
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
|
|
7
|
+
# π **azauthlib** π
|
|
8
|
+
|
|
9
|
+
> **Your Simplified Authentication Companion for Azure Microsoft Graph**
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
`azauthlib` is a Python library that **streamlines the authentication process** with Azure Microsoft Graph. From interactive logins to client credentials flow, `azauthlib` provides an intuitive interface, robust token management, and a GUI for seamless configuration.
|
|
15
|
+
|
|
16
|
+
π Whether you're building applications that interact with Microsoft Graph APIs or automating workflows, `azauthlib` has you covered.
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+

|
|
20
|
+

|
|
21
|
+

|
|
22
|
+

|
|
23
|
+

|
|
24
|
+

|
|
25
|
+

|
|
26
|
+

|
|
27
|
+

|
|
28
|
+

|
|
29
|
+

|
|
30
|
+

|
|
31
|
+

|
|
32
|
+

|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## β¨ **Features** β¨
|
|
36
|
+
|
|
37
|
+
β
**Multiple Authentication Flows**
|
|
38
|
+
- Silent Authentication
|
|
39
|
+
- Interactive Authentication
|
|
40
|
+
- Device Code Flow
|
|
41
|
+
- Client Credentials
|
|
42
|
+
|
|
43
|
+
β
**Graphical User Interface (GUI)**
|
|
44
|
+
- Configure credentials with an easy-to-use GUI.
|
|
45
|
+
|
|
46
|
+
β
**Token Management**
|
|
47
|
+
- Automatic refresh for access tokens
|
|
48
|
+
- Secure token storage
|
|
49
|
+
|
|
50
|
+
β
**Flexible Environment Configuration**
|
|
51
|
+
- Use `.env` files, OS variables, or direct input.
|
|
52
|
+
|
|
53
|
+
β
**Customizable Permissions**
|
|
54
|
+
- Specify Microsoft Graph API scopes effortlessly.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## π **Installation**
|
|
59
|
+
|
|
60
|
+
### Install from PyPI
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install azauthlib
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Install from Source
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git clone https://github.com/cedricmoorejr/azauthlib.git
|
|
70
|
+
cd azauthlib
|
|
71
|
+
pip install .
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### π **Requirements**
|
|
75
|
+
- Python 3.7+
|
|
76
|
+
- `msal`
|
|
77
|
+
- `portalocker`
|
|
78
|
+
- `python-dotenv`
|
|
79
|
+
|
|
80
|
+
Install dependencies manually if needed:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install -r requirements.txt
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## π **Getting Started**
|
|
89
|
+
|
|
90
|
+
### 1οΈβ£ **Prerequisites**
|
|
91
|
+
- Register an app in **Azure Active Directory** via the [Azure Portal](https://portal.azure.com/).
|
|
92
|
+
- Collect the following:
|
|
93
|
+
- `CLIENT_ID`
|
|
94
|
+
- `TENANT_ID`
|
|
95
|
+
- (Optional) `CLIENT_SECRET`
|
|
96
|
+
|
|
97
|
+
- Assign the appropriate Microsoft Graph API permissions.
|
|
98
|
+
|
|
99
|
+
### 2οΈβ£ **Configuration Options**
|
|
100
|
+
#### π **Option A: GUI Mode**
|
|
101
|
+
|
|
102
|
+
Launch the GUI for intuitive configuration:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
python config_app.py
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> π‘ **What You Can Do in the GUI:**
|
|
109
|
+
> - Enter credentials (`CLIENT_ID`, `TENANT_ID`, etc.).
|
|
110
|
+
> - Choose your authentication method.
|
|
111
|
+
> - Credentials are saved securely in a `.env` file.
|
|
112
|
+
|
|
113
|
+

|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
#### π **Option B: Non-GUI Mode**
|
|
118
|
+
|
|
119
|
+
1. **Using Environment Variables** (Recommended):
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
export TENANT_ID="your-tenant-id"
|
|
123
|
+
export CLIENT_ID="your-client-id"
|
|
124
|
+
export CLIENT_SECRET="your-client-secret"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
2. **Hardcoding in Code** (β οΈ Not Recommended):
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from azauthlib import Authentication
|
|
131
|
+
|
|
132
|
+
auth = Authentication(scopes="Files.ReadWrite.All")
|
|
133
|
+
auth.Build.WithEntry(
|
|
134
|
+
client_id="your-client-id",
|
|
135
|
+
tenant_id="your-tenant-id",
|
|
136
|
+
client_secret="your-client-secret"
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## π **Authentication Flows**
|
|
143
|
+
|
|
144
|
+
### π **Silent Authentication**
|
|
145
|
+
Authenticate using cached tokens.
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
auth.Silent()
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### π **Interactive Authentication**
|
|
152
|
+
Prompts user to log in via a browser.
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
auth.Interactive()
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### π± **Device Code Flow**
|
|
159
|
+
Displays a device code for cross-device authentication.
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
auth.DeviceCodeFlow(webbrowser_enabled=True)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### π€ **Client Credentials Flow**
|
|
166
|
+
Authenticate server-to-server.
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
auth.ClientCredentials()
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## πΌ **Token Management**
|
|
175
|
+
|
|
176
|
+
- **Access Token**: Retrieve the active token.
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
token = auth.access_token
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
- **Token Expiry**: Check token lifetime.
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
print("Token expires in:", auth.token_expires_in)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- **Automatic Refresh**: Tokens are refreshed seamlessly.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## π **Logging**
|
|
193
|
+
|
|
194
|
+
Easily track authentication flow and token operations using Pythonβs `logging` module. Customize as needed!
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## π€ **Contributing**
|
|
199
|
+
|
|
200
|
+
We welcome contributions! π Here's how you can help:
|
|
201
|
+
1. Fork the repo.
|
|
202
|
+
2. Create a feature or bugfix branch.
|
|
203
|
+
3. Submit a PR with a detailed description.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## π **License**
|
|
208
|
+
|
|
209
|
+
This project is licensed under the **Apache License 2.0**. See the `LICENSE` file for more details.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## βΉοΈ **Trademarks**
|
|
214
|
+
|
|
215
|
+
- This project references **Microsoft** trademarks such as Azure and Microsoft Graph. Please ensure compliance with Microsoftβs [Trademark Guidelines](https://www.microsoft.com/trademarks).
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
π **[GitHub Repository](https://github.com/cedricmoorejr/azauthlib/tree/v1.0.0b1)**
|
|
220
|
+
π¬ **Feedback? Issues?** Weβd love to hear from you!
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# main
|
|
2
|
+
__all__ = ['Authentication']
|
|
3
|
+
|
|
4
|
+
# Explicit imports
|
|
5
|
+
from .authentication import Authentication
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# import os
|
|
9
|
+
# import sys
|
|
10
|
+
#
|
|
11
|
+
# # Absolute path of this package's directory
|
|
12
|
+
# PACKAGEPATH = os.path.abspath(os.path.dirname(__file__))
|
|
13
|
+
#
|
|
14
|
+
# # Add the package path to sys.path
|
|
15
|
+
# if PACKAGEPATH not in sys.path:
|
|
16
|
+
# sys.path.append(PACKAGEPATH)
|
|
17
|
+
#
|
|
18
|
+
# # # Define HOMEPATH for general usage
|
|
19
|
+
# # HOMEPATH = os.path.dirname(PACKAGEPATH)
|
|
20
|
+
#
|
|
21
|
+
# from authentication import Authentication
|
|
22
|
+
#
|
|
23
|
+
# __all__ = ['Authentication']
|