Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Using inline comments in configuration samples
  • Loading branch information
rayluo committed Apr 15, 2019
commit 79ec0a37fc99a45325f94a1261712d17a9d51c8e
16 changes: 8 additions & 8 deletions sample/certificate_credential_sample.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"""
The configuration file would look like this:
The configuration file would look like this (sans those // comments):

{
"authority": "https://login.microsoftonline.com/organizations",
"client_id": "your_client_id",
"scope": ["https://graph.microsoft.com/.default"],
"thumbprint": "790E20ED5C5BF7F44..."
// For more information about scopes for an app, refer:
// https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#second-case-access-token-request-with-a-certificate"

"thumbprint": "790E... The thumbprint generated by AAD when you upload your public cert",
"private_key_file": "filename.pem"
// For information about generating thumbprint and private key file, refer:
// https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Client-Credentials#client-credentials-with-certificate
}
For more information about scopes, refer:
https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#second-case-access-token-request-with-a-certificate

For more information about generating thumbprint and private key file, refer:
https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Client-credentials

You can then run this sample with a JSON configuration file:

Expand All @@ -34,7 +34,7 @@
# Create a preferably long-lived app instance which maintains a token cache.
app = msal.ConfidentialClientApplication(
config["client_id"], authority=config["authority"],
client_credential={"thumbprint": config["thumbprint"], "private_key": open(config['private_key_file']).read()}
client_credential={"thumbprint": config["thumbprint"], "private_key": open(config['private_key_file']).read()},
# token_cache=... # Default cache is in memory only.
# You can learn how to use SerializableTokenCache from
# https://msal-python.rtfd.io/en/latest/#msal.SerializableTokenCache
Expand Down
10 changes: 8 additions & 2 deletions sample/client_credential_sample.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
"""
The configuration file would look like this:
The configuration file would look like this (sans those // comments):

{
"authority": "https://login.microsoftonline.com/organizations",
"client_id": "your_client_id",
"scope": ["https://graph.microsoft.com/.default"],
"secret": "This is a sample only. You better NOT persist your password."
// For more information about scopes for an app, refer:
// https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#second-case-access-token-request-with-a-certificate"

"secret": "The secret generated by AAD during your confidential app registration"
// For information about generating client secret, refer:
// https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Client-Credentials#registering-client-secrets-using-the-application-registration-portal

}

You can then run this sample with a JSON configuration file:
Expand Down