Skip to content

Commit 712e16d

Browse files
committed
Introduced filestorage & partners namespaces, fixes for revoke_delegated_permissions method
1 parent 39644e6 commit 712e16d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+503
-68
lines changed

examples/auth/__init__.py

Whitespace-only changes.

examples/auth/delegated.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
AdministrativeUnit.ReadWrite.All
2+
Application.Read.All
3+
Application.ReadWrite.All
4+
AuditLog.Read.All
5+
BackupRestore-Control.Read.All
6+
Bookings.Manage.All
7+
Calendars.ReadWrite.Shared
8+
ChannelMember.ReadWrite.All
9+
ChannelMessage.ReadWrite
10+
Chat.ReadWrite
11+
Chat.ReadWrite.All
12+
DeviceLocalCredential.Read.All
13+
DeviceManagementConfiguration.Read.All
14+
DeviceManagementManagedDevices.ReadWrite.All
15+
Directory.AccessAsUser.All
16+
Directory.ReadWrite.All
17+
Domain.ReadWrite.All
18+
Files.Read.All
19+
Files.ReadWrite.All
20+
Group.Read.All
21+
Group.ReadWrite.All
22+
Mail.ReadWrite
23+
MailboxSettings.ReadWrite
24+
Notes.Create
25+
Notes.ReadWrite.All
26+
OnlineMeetings.ReadWrite
27+
Presence.Read.All
28+
Presence.ReadWrite
29+
Reports.Read.All
30+
ServiceHealth.Read.All
31+
SharePointTenantSettings.ReadWrite.All
32+
Sites.Manage.All
33+
Sites.ReadWrite.All
34+
Tasks.ReadWrite
35+
Tasks.ReadWrite.Shared
36+
Team.ReadBasic.All
37+
TeamMember.ReadWrite.All
38+
ThreatAssessment.ReadWrite.All
39+
User.ReadWrite.All
40+
UserActivity.ReadWrite.CreatedByApp
41+
UserAuthenticationMethod.Read.All
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Demonstrates how to login when the user may be prompted for input by the authorization server.
3+
For example, to sign in, perform multi-factor authentication (MFA), or to grant consent
4+
to more resource access permissions.
5+
6+
Prerequisite: In Azure Portal, configure the Redirect URI of your
7+
"Mobile and Desktop application" as ``http://localhost``.
8+
9+
https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#interactive-and-non-interactive-authentication
10+
"""
11+
12+
from office365.sharepoint.client_context import ClientContext
13+
from tests import test_client_id, test_site_url, test_tenant
14+
15+
ctx = ClientContext(test_site_url).with_interactive(test_tenant, test_client_id)
16+
me = ctx.web.current_user.get().execute_query()
17+
web = ctx.web.get().execute_query()
18+
print(me.login_name)
19+
print(web.title)

examples/auth/register_sharepoint_apponly.py renamed to examples/auth/sharepoint/register_apponly.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
openssl req -x509 -newkey rsa:2048 -keyout selfsignkey.pem -out selfsigncert.pem -nodes -days 365
1010
1111
2. register Azure AD application
12-
3. add permissions
13-
4. upload certificate (public key)
12+
3. assign permissions (for instance Sites.FullControl.All permission)
13+
4. grant Admin Consent.
14+
4. create and upload certificate (public key).
15+
5. assign App-Only Role to SharePoint.
1416
1517
"""
1618

examples/directory/applications/grant_delegated_perms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
resource = client.service_principals.get_by_name("Microsoft Graph")
24-
# app_role = "User.Read.All"
25-
app_role = "DeviceLocalCredential.Read.All"
24+
app_role = "FileStorageContainer.Selected"
2625
user = client.users.get_by_principal_name(test_user_principal_name)
2726
resource.grant_delegated_permissions(test_client_id, user, app_role).execute_query()

examples/directory/applications/has_delegated_perms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
)
1818

1919
resource = client.service_principals.get_by_name("Microsoft Graph")
20-
scope = "DeviceLocalCredential.Read.All"
20+
scope = "FileStorageContainer.Selected"
2121
user = client.users.get_by_principal_name(test_admin_principal_name)
2222
client_app = client.applications.get_by_app_id(test_client_id)
23-
# result = resource.get_delegated_permissions(test_client_id, user).execute_query()
2423
result = resource.get_delegated_permissions(test_client_id).execute_query()
2524
if len([cur_scope for cur_scope in result.value if cur_scope == scope]) == 0:
2625
print("Delegated permission '{0}' is not granted".format(scope))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
Disable MFA
3+
"""
4+
5+
from office365.graph_client import GraphClient
6+
from tests import test_client_id, test_password, test_tenant, test_username
7+
8+
client = GraphClient(tenant=test_tenant).with_username_and_password(
9+
test_client_id, test_username, test_password
10+
)
11+
12+
resource = client.service_principals.get_by_name("Microsoft Graph")
13+
14+
# resource.revoke_delegated_permissions(test_client_id).execute_query()
15+
16+
resource.grant_delegated_permissions(
17+
test_client_id, None, "UserAuthenticationMethod.ReadWrite"
18+
).execute_query()
19+
20+
methods = client.me.authentication.microsoft_authenticator_methods.get().execute_query()
21+
for method in methods:
22+
method.delete_object().execute_query()

generator/import_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def export_to_file(path, content):
2626
"--endpoint",
2727
dest="endpoint",
2828
help="Import metadata endpoint",
29-
default="graph",
29+
default="sharepoint",
3030
)
3131
parser.add_argument(
3232
"-p",
3333
"--path",
3434
dest="path",
35-
default="./metadata/Graph.xml",
35+
default="./metadata/SharePoint.xml",
3636
help="Import metadata endpoint",
3737
)
3838

generator/metadata/Graph.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20466,6 +20466,11 @@ within the time frame of their original request."/>
2046620466
<Member Name="selfRenew" Value="9"/>
2046720467
<Member Name="unknownFutureValue" Value="10"/>
2046820468
</EnumType>
20469+
<EnumType Name="incompatiblePrinterSettings">
20470+
<Member Name="show" Value="0"/>
20471+
<Member Name="hide" Value="1"/>
20472+
<Member Name="unknownFutureValue" Value="2"/>
20473+
</EnumType>
2046920474
<EnumType Name="printColorMode">
2047020475
<Member Name="blackAndWhite" Value="0"/>
2047120476
<Member Name="grayscale" Value="1"/>
@@ -33115,6 +33120,9 @@ within the time frame of their original request."/>
3311533120
<Property Name="notificationType" Type="Edm.String"/>
3311633121
<Property Name="recipientType" Type="Edm.String"/>
3311733122
</EntityType>
33123+
<ComplexType Name="airPrintSettings">
33124+
<Property Name="incompatiblePrinters" Type="graph.incompatiblePrinterSettings" Nullable="false"/>
33125+
</ComplexType>
3311833126
<ComplexType Name="archivedPrintJob">
3311933127
<Property Name="acquiredByPrinter" Type="Edm.Boolean" Nullable="false"/>
3312033128
<Property Name="acquiredDateTime" Type="Edm.DateTimeOffset"/>
@@ -33186,6 +33194,9 @@ within the time frame of their original request."/>
3318633194
<Property Name="quality" Type="graph.printQuality"/>
3318733195
<Property Name="scaling" Type="graph.printScaling"/>
3318833196
</ComplexType>
33197+
<ComplexType Name="printerDiscoverySettings">
33198+
<Property Name="airPrint" Type="graph.airPrintSettings" Nullable="false"/>
33199+
</ComplexType>
3318933200
<ComplexType Name="printerLocation">
3319033201
<Property Name="altitudeInMeters" Type="Edm.Int32"/>
3319133202
<Property Name="building" Type="Edm.String"/>
@@ -33252,6 +33263,7 @@ within the time frame of their original request."/>
3325233263
</ComplexType>
3325333264
<ComplexType Name="printSettings">
3325433265
<Property Name="documentConversionEnabled" Type="Edm.Boolean" Nullable="false"/>
33266+
<Property Name="printerDiscoverySettings" Type="graph.printerDiscoverySettings"/>
3325533267
</ComplexType>
3325633268
<ComplexType Name="printTaskStatus">
3325733269
<Property Name="description" Type="Edm.String" Nullable="false"/>
@@ -33317,16 +33329,20 @@ within the time frame of their original request."/>
3331733329
<EntityType Name="printDocument" BaseType="graph.entity" HasStream="true">
3331833330
<Property Name="contentType" Type="Edm.String"/>
3331933331
<Property Name="displayName" Type="Edm.String"/>
33332+
<Property Name="downloadedDateTime" Type="Edm.DateTimeOffset"/>
3332033333
<Property Name="size" Type="Edm.Int64" Nullable="false"/>
33334+
<Property Name="uploadedDateTime" Type="Edm.DateTimeOffset"/>
3332133335
</EntityType>
3332233336
<EntityType Name="printTaskTrigger" BaseType="graph.entity">
3332333337
<Property Name="event" Type="graph.printEvent" Nullable="false"/>
3332433338
<NavigationProperty Name="definition" Type="graph.printTaskDefinition" Nullable="false"/>
3332533339
</EntityType>
3332633340
<EntityType Name="printJob" BaseType="graph.entity">
33341+
<Property Name="acknowledgedDateTime" Type="Edm.DateTimeOffset"/>
3332733342
<Property Name="configuration" Type="graph.printJobConfiguration" Nullable="false"/>
3332833343
<Property Name="createdBy" Type="graph.userIdentity"/>
3332933344
<Property Name="createdDateTime" Type="Edm.DateTimeOffset" Nullable="false"/>
33345+
<Property Name="errorCode" Type="Edm.Int32"/>
3333033346
<Property Name="isFetchable" Type="Edm.Boolean" Nullable="false"/>
3333133347
<Property Name="redirectedFrom" Type="Edm.String"/>
3333233348
<Property Name="redirectedTo" Type="Edm.String"/>

0 commit comments

Comments
 (0)