You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+44-20
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
2
2
# Microsoft Authentication Extensions for Python
3
3
4
-
The Microsoft Authentication Extensions for Python offers secure mechanisms for client applications to perform cross-platform token cache serialization and persistence. It gives additional support to the [Microsoft Authentication Library for Python (MSAL)](https://github.com/AzureAD/microsoft-authentication-library-for-python).
4
+
The Microsoft Authentication Extensions for Python offers secure mechanisms for client applications to perform cross-platform token cache serialization and persistence. It gives additional support to the [Microsoft Authentication Library for Python (MSAL)](https://github.com/AzureAD/microsoft-authentication-library-for-python).
5
5
6
6
MSAL Python supports an in-memory cache by default and provides the [SerializableTokenCache](https://msal-python.readthedocs.io/en/latest/#msal.SerializableTokenCache) to perform cache serialization. You can read more about this in the MSAL Python [documentation](https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-python-token-cache-serialization). Developers are required to implement their own cache persistance across multiple platforms and Microsoft Authentication Extensions makes this simpler.
7
7
8
-
The supported platforms are Windows, Mac and Linux.
8
+
The supported platforms are Windows, Mac and Linux.
9
9
- Windows - [DPAPI](https://docs.microsoft.com/en-us/dotnet/standard/security/how-to-use-data-protection) is used for encryption.
10
10
- MAC - The MAC KeyChain is used.
11
11
- Linux - [LibSecret](https://wiki.gnome.org/Projects/Libsecret) is used for encryption.
@@ -28,7 +28,9 @@ You can find the changes for each version under
28
28
29
29
## Usage
30
30
31
-
The Microsoft Authentication Extensions library provides the `PersistedTokenCache` which accepts a platform-dependent persistence instance. This token cache can then be used to instantiate the `PublicClientApplication` in MSAL Python.
31
+
### Creating an encrypted token cache file to be used by MSAL
32
+
33
+
The Microsoft Authentication Extensions library provides the `PersistedTokenCache` which accepts a platform-dependent persistence instance. This token cache can then be used to instantiate the `PublicClientApplication` in MSAL Python.
32
34
33
35
The token cache includes a file lock, and auto-reload behavior under the hood.
34
36
@@ -39,24 +41,16 @@ Here is an example of this pattern for multiple platforms (taken from the comple
### Creating an encrypted persistence file to store your own data
64
+
65
+
Here is an example of this pattern for multiple platforms (taken from the complete [sample here](https://github.com/AzureAD/microsoft-authentication-extensions-for-python/blob/dev/sample/persistence_sample.py)):
print("Type of persistence: {}".format(persistence.__class__.__name__))
80
+
print("Is this persistence encrypted?", persistence.is_encrypted)
81
+
82
+
data = { # It can be anything, here we demonstrate an arbitrary json object
83
+
"foo": "hello world",
84
+
"bar": "",
85
+
"service_principle_1": "blah blah...",
86
+
}
87
+
88
+
persistence.save(json.dumps(data))
89
+
assert json.loads(persistence.load()) == data
90
+
```
91
+
92
+
69
93
## Community Help and Support
70
94
71
95
We leverage Stack Overflow to work with the community on supporting Azure Active Directory and its SDKs, including this one!
@@ -92,4 +116,4 @@ provided by the bot. You will only need to do this once across all repos using o
92
116
93
117
## We value and adhere to the Microsoft Open Source Code of Conduct
94
118
95
-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
119
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
0 commit comments