Skip to content

Commit 6504657

Browse files
authored
Update README.md
1 parent 795723f commit 6504657

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,41 @@ The easiest way to filter this decision is by looking at the permissions set you
2727
- Application permissions are used when you don’t need a user to login to your app, but the app will perform tasks on its own and run in the background.
2828
- Delegated permissions, also called scopes, are used when your app requires a user to login and interact with data related to this user in a session.
2929

30-
In this demo we'll use the 2 most common scenarios: client secret credentials for application permissions and device code credentials for delegated permissions. You can also use environment credentials, interactive browser credentials, default azure credentials, on-behalf-of credentials, or any other Azure Identity library.
30+
The following table lists common libraries by permissions set.
31+
| MSAL library | Permissions set | Common use case |
32+
|---|---|---|
33+
| [ClientSecretCredential](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.aio.clientsecretcredential?view=azure-python&preserve-view=true) | Application permissions | Daemon apps or applications running in the background without a signed-in user. |
34+
| [DeviceCodeCredential](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.devicecodecredential?view=azure-python) | Delegated permissions | Enviroments where authentication is triggered in one machine and completed in another e.g in a cloud server. |
35+
| [InteractiveBrowserCredentials](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.interactivebrowsercredential?view=azure-python) | Delegated permissions | Environments where a browser is available and the user wants to key in their username/password. |
36+
| [AuthorizationCodeCredentials](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.authorizationcodecredential?view=azure-python) | Delegated permissions | Usually for custom customer applications where the frontend calls the backend and waits for the authorization code at a particular url. |
37+
38+
You can also use [EnvironmentCredential](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.environmentcredential?view=azure-python), [DefaultAzureCredential](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python), [OnBehalfOfCredential](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.onbehalfofcredential?view=azure-python), or any other [Azure Identity library](https://learn.microsoft.com/en-us/python/api/overview/azure/identity-readme?view=azure-python#credential-classes).
39+
40+
Once you've picked an authentication library, we can initiate the authentication provider in your app. The following example uses ClientSecretCredential with application permissions.
41+
```python
42+
import asyncio
43+
44+
from azure.identity.aio import ClientSecretCredential
45+
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
46+
47+
credential = ClientSecretCredential("tenantID",
48+
"clientID",
49+
"clientSecret")
50+
scopes = ['https://graph.microsoft.com/.default']
51+
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=scopes)
52+
```
53+
54+
The following example uses DeviceCodeCredentials with delegated permissions.
55+
```python
56+
import asyncio
57+
58+
from azure.identity import DeviceCodeCredential
59+
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
60+
61+
credential = DeviceCodeCredential(client_id, tenant_id)
62+
graph_scopes = ['User.Read', 'Calendars.ReadWrite.Shared']
63+
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=graph_scopes)
64+
```
3165

3266
### 2.3 Initialize a GraphServiceClient object
3367

0 commit comments

Comments
 (0)