Skip to content

Commit

Permalink
#713: support for oauth2 device code auth introduced
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Jul 22, 2023
1 parent 8f49845 commit 2b603f5
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 9 deletions.
15 changes: 15 additions & 0 deletions examples/sharepoint/connect_device_flow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Demonstrates how to authenticate users on devices or operating systems that don't provide a web browser.
Device code flow lets the user use another device such as a computer or a mobile phone to sign in interactively.
https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code
"""

from office365.sharepoint.client_context import ClientContext
from tests import test_tenant, test_client_id, test_site_url

ctx = ClientContext(test_site_url).with_device_flow(test_tenant, test_client_id)
me = ctx.web.current_user.get().execute_query()
print(me.login_name)
web = ctx.web.get().execute_query()
print(web.title)
4 changes: 2 additions & 2 deletions generator/import_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def export_to_file(path, content):

parser = ArgumentParser()
parser.add_argument("-e", "--endpoint", dest="endpoint",
help="Import metadata endpoint", default="sharepoint")
help="Import metadata endpoint", default="microsoftgraph")
parser.add_argument("-p", "--path",
dest="path", default="./metadata/SharePoint.xml",
dest="path", default="./metadata/MicrosoftGraph.xml",
help="Import metadata endpoint")

args = parser.parse_args()
Expand Down
135 changes: 130 additions & 5 deletions generator/metadata/MicrosoftGraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25406,14 +25406,20 @@
</ComplexType>
<ComplexType Name="conditionalAccessAllExternalTenants" BaseType="graph.conditionalAccessExternalTenants"/>
<ComplexType Name="conditionalAccessApplications">
<Property Name="applicationFilter" Type="graph.conditionalAccessFilter"/>
<Property Name="excludeApplications" Type="Collection(Edm.String)" Nullable="false"/>
<Property Name="includeApplications" Type="Collection(Edm.String)" Nullable="false"/>
<Property Name="includeAuthenticationContextClassReferences" Type="Collection(Edm.String)" Nullable="false"/>
<Property Name="includeUserActions" Type="Collection(Edm.String)" Nullable="false"/>
</ComplexType>
<ComplexType Name="conditionalAccessFilter">
<Property Name="mode" Type="graph.filterMode" Nullable="false"/>
<Property Name="rule" Type="Edm.String" Nullable="false"/>
</ComplexType>
<ComplexType Name="conditionalAccessClientApplications">
<Property Name="excludeServicePrincipals" Type="Collection(Edm.String)" Nullable="false"/>
<Property Name="includeServicePrincipals" Type="Collection(Edm.String)" Nullable="false"/>
<Property Name="servicePrincipalFilter" Type="graph.conditionalAccessFilter"/>
</ComplexType>
<ComplexType Name="conditionalAccessConditionSet">
<Property Name="applications" Type="graph.conditionalAccessApplications"/>
Expand Down Expand Up @@ -25448,10 +25454,6 @@
<Property Name="includeRoles" Type="Collection(Edm.String)" Nullable="false"/>
<Property Name="includeUsers" Type="Collection(Edm.String)" Nullable="false"/>
</ComplexType>
<ComplexType Name="conditionalAccessFilter">
<Property Name="mode" Type="graph.filterMode" Nullable="false"/>
<Property Name="rule" Type="Edm.String" Nullable="false"/>
</ComplexType>
<ComplexType Name="conditionalAccessEnumeratedExternalTenants" BaseType="graph.conditionalAccessExternalTenants">
<Property Name="members" Type="Collection(Edm.String)" Nullable="false"/>
</ComplexType>
Expand Down Expand Up @@ -30510,9 +30512,13 @@
<NavigationProperty Name="bot" Type="graph.teamworkBot" ContainsTarget="true"/>
</EntityType>
<EntityType Name="teamworkBot" BaseType="graph.entity"/>
<EntityType Name="teamsAppSettings" BaseType="graph.entity">
<Property Name="allowUserRequestsForAppAccess" Type="Edm.Boolean"/>
</EntityType>
<EntityType Name="teamwork" BaseType="graph.entity">
<NavigationProperty Name="workforceIntegrations" Type="Collection(graph.workforceIntegration)" ContainsTarget="true"/>
<NavigationProperty Name="deletedTeams" Type="Collection(graph.deletedTeam)" ContainsTarget="true"/>
<NavigationProperty Name="teamsAppSettings" Type="graph.teamsAppSettings" ContainsTarget="true"/>
</EntityType>
<EntityType Name="workforceIntegration" BaseType="graph.changeTrackedEntity">
<Property Name="apiVersion" Type="Edm.Int32"/>
Expand Down Expand Up @@ -36065,7 +36071,6 @@
</EntitySet>
<EntitySet Name="groupSettings" EntityType="microsoft.graph.groupSetting"/>
<EntitySet Name="groupSettingTemplates" EntityType="microsoft.graph.groupSettingTemplate"/>
<EntitySet Name="localizations" EntityType="microsoft.graph.organizationalBrandingLocalization"/>
<EntitySet Name="oauth2PermissionGrants" EntityType="microsoft.graph.oAuth2PermissionGrant"/>
<EntitySet Name="organization" EntityType="microsoft.graph.organization">
<NavigationPropertyBinding Path="certificateBasedAuthConfiguration" Target="certificateBasedAuthConfiguration"/>
Expand Down Expand Up @@ -36292,6 +36297,12 @@
<Member Name="resolved" Value="8"/>
<Member Name="unknownFutureValue" Value="31"/>
</EnumType>
<EnumType Name="containerPortProtocol">
<Member Name="udp" Value="0"/>
<Member Name="tcp" Value="1"/>
<Member Name="sctp" Value="2"/>
<Member Name="unknownFutureValue" Value="3"/>
</EnumType>
<EnumType Name="defenderAvStatus">
<Member Name="notReporting" Value="0"/>
<Member Name="disabled" Value="1"/>
Expand Down Expand Up @@ -36378,6 +36389,14 @@
<Member Name="noThreatsFound" Value="3"/>
<Member Name="unknownFutureValue" Value="4"/>
</EnumType>
<EnumType Name="fileHashAlgorithm">
<Member Name="unknown" Value="0"/>
<Member Name="md5" Value="1"/>
<Member Name="sha1" Value="2"/>
<Member Name="sha256" Value="3"/>
<Member Name="sha256ac" Value="4"/>
<Member Name="unknownFutureValue" Value="5"/>
</EnumType>
<EnumType Name="googleCloudLocationType">
<Member Name="unknown" Value="0"/>
<Member Name="regional" Value="1"/>
Expand All @@ -36393,6 +36412,22 @@
<Member Name="unknownFutureValue" Value="127"/>
<Member Name="awaitingAction" Value="128"/>
</EnumType>
<EnumType Name="kubernetesPlatform">
<Member Name="unknown" Value="0"/>
<Member Name="aks" Value="1"/>
<Member Name="eks" Value="2"/>
<Member Name="gke" Value="3"/>
<Member Name="arc" Value="4"/>
<Member Name="unknownFutureValue" Value="5"/>
</EnumType>
<EnumType Name="kubernetesServiceType">
<Member Name="unknown" Value="0"/>
<Member Name="clusterIP" Value="1"/>
<Member Name="externalName" Value="2"/>
<Member Name="nodePort" Value="3"/>
<Member Name="loadBalancer" Value="4"/>
<Member Name="unknownFutureValue" Value="31"/>
</EnumType>
<EnumType Name="onboardingStatus">
<Member Name="insufficientInfo" Value="0"/>
<Member Name="onboarded" Value="1"/>
Expand Down Expand Up @@ -36758,13 +36793,57 @@
<Property Name="resourceName" Type="Edm.String"/>
<Property Name="resourceType" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="blobContainerEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="name" Type="Edm.String"/>
<Property Name="storageResource" Type="microsoft.graph.security.azureResourceEvidence"/>
<Property Name="url" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="blobEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="blobContainer" Type="microsoft.graph.security.blobContainerEvidence"/>
<Property Name="etag" Type="Edm.String"/>
<Property Name="fileHashes" Type="Collection(microsoft.graph.security.fileHash)"/>
<Property Name="name" Type="Edm.String"/>
<Property Name="url" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="fileHash">
<Property Name="algorithm" Type="microsoft.graph.security.fileHashAlgorithm" Nullable="false"/>
<Property Name="value" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="cloudApplicationEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="appId" Type="Edm.Int64"/>
<Property Name="displayName" Type="Edm.String"/>
<Property Name="instanceId" Type="Edm.Int64"/>
<Property Name="instanceName" Type="Edm.String"/>
<Property Name="saasAppId" Type="Edm.Int64"/>
</ComplexType>
<ComplexType Name="containerEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="args" Type="Collection(Edm.String)"/>
<Property Name="command" Type="Collection(Edm.String)"/>
<Property Name="containerId" Type="Edm.String"/>
<Property Name="image" Type="microsoft.graph.security.containerImageEvidence"/>
<Property Name="isPrivileged" Type="Edm.Boolean" Nullable="false"/>
<Property Name="name" Type="Edm.String"/>
<Property Name="pod" Type="microsoft.graph.security.kubernetesPodEvidence"/>
</ComplexType>
<ComplexType Name="containerImageEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="digestImage" Type="microsoft.graph.security.containerImageEvidence"/>
<Property Name="imageId" Type="Edm.String"/>
<Property Name="registry" Type="microsoft.graph.security.containerRegistryEvidence"/>
</ComplexType>
<ComplexType Name="kubernetesPodEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="containers" Type="Collection(microsoft.graph.security.containerEvidence)"/>
<Property Name="controller" Type="microsoft.graph.security.kubernetesControllerEvidence"/>
<Property Name="ephemeralContainers" Type="Collection(microsoft.graph.security.containerEvidence)"/>
<Property Name="initContainers" Type="Collection(microsoft.graph.security.containerEvidence)"/>
<Property Name="labels" Type="microsoft.graph.security.dictionary"/>
<Property Name="name" Type="Edm.String"/>
<Property Name="namespace" Type="microsoft.graph.security.kubernetesNamespaceEvidence"/>
<Property Name="podIp" Type="microsoft.graph.security.ipEvidence"/>
<Property Name="serviceAccount" Type="microsoft.graph.security.kubernetesServiceAccountEvidence"/>
</ComplexType>
<ComplexType Name="containerRegistryEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="registry" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="deviceEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="azureAdDeviceId" Type="Edm.String"/>
<Property Name="defenderAvStatus" Type="microsoft.graph.security.defenderAvStatus"/>
Expand Down Expand Up @@ -36793,6 +36872,7 @@
<Property Name="subscriptionId" Type="Edm.String"/>
<Property Name="vmId" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="dictionary" OpenType="true"/>
<ComplexType Name="dynamicColumnValue" OpenType="true"/>
<ComplexType Name="fileDetails">
<Property Name="fileName" Type="Edm.String"/>
Expand Down Expand Up @@ -36830,6 +36910,51 @@
<Property Name="countryLetterCode" Type="Edm.String"/>
<Property Name="ipAddress" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="kubernetesClusterEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="cloudResource" Type="microsoft.graph.security.alertEvidence"/>
<Property Name="distribution" Type="Edm.String"/>
<Property Name="name" Type="Edm.String"/>
<Property Name="platform" Type="microsoft.graph.security.kubernetesPlatform"/>
<Property Name="version" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="kubernetesControllerEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="labels" Type="microsoft.graph.security.dictionary"/>
<Property Name="name" Type="Edm.String"/>
<Property Name="namespace" Type="microsoft.graph.security.kubernetesNamespaceEvidence"/>
<Property Name="type" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="kubernetesNamespaceEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="cluster" Type="microsoft.graph.security.kubernetesClusterEvidence"/>
<Property Name="labels" Type="microsoft.graph.security.dictionary"/>
<Property Name="name" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="kubernetesServiceAccountEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="name" Type="Edm.String"/>
<Property Name="namespace" Type="microsoft.graph.security.kubernetesNamespaceEvidence"/>
</ComplexType>
<ComplexType Name="kubernetesSecretEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="name" Type="Edm.String"/>
<Property Name="namespace" Type="microsoft.graph.security.kubernetesNamespaceEvidence"/>
<Property Name="secretType" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="kubernetesServiceEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="clusterIP" Type="microsoft.graph.security.ipEvidence"/>
<Property Name="externalIPs" Type="Collection(microsoft.graph.security.ipEvidence)"/>
<Property Name="labels" Type="microsoft.graph.security.dictionary"/>
<Property Name="name" Type="Edm.String"/>
<Property Name="namespace" Type="microsoft.graph.security.kubernetesNamespaceEvidence"/>
<Property Name="selector" Type="microsoft.graph.security.dictionary"/>
<Property Name="servicePorts" Type="Collection(microsoft.graph.security.kubernetesServicePort)"/>
<Property Name="serviceType" Type="microsoft.graph.security.kubernetesServiceType" Nullable="false"/>
</ComplexType>
<ComplexType Name="kubernetesServicePort">
<Property Name="appProtocol" Type="Edm.String"/>
<Property Name="name" Type="Edm.String"/>
<Property Name="nodePort" Type="Edm.Int32" Nullable="false"/>
<Property Name="port" Type="Edm.Int32" Nullable="false"/>
<Property Name="protocol" Type="microsoft.graph.security.containerPortProtocol"/>
<Property Name="targetPort" Type="Edm.String"/>
</ComplexType>
<ComplexType Name="mailboxEvidence" BaseType="microsoft.graph.security.alertEvidence">
<Property Name="displayName" Type="Edm.String"/>
<Property Name="primaryAddress" Type="Edm.String"/>
Expand Down
Loading

0 comments on commit 2b603f5

Please sign in to comment.