🔍 Code Extractor

class AppConsentRequest

Maturity: 52

Represents a user's request to a tenant admin for consent to access an app or grant permissions to an app, used in Microsoft Graph API identity governance workflows.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/appconsent/request.py
Lines:
8 - 26
Complexity:
moderate

Purpose

This class models an app consent request entity in Microsoft's identity governance system. It encapsulates the details of a user's request for admin authorization to access an app or grant specific permissions. The class is used when the admin consent workflow is enabled and an app or permission requires administrative approval. It provides access to associated user consent requests through a collection property.

Source Code

class AppConsentRequest(Entity):
    """
    Represents the request that a user creates when they request the tenant admin for consent to access an app or
    to grant permissions to an app. The details include the app that the user wants access to be granted to on their
    behalf and the permissions that the user is requesting.

    The user can create a consent request when an app or a permission requires admin authorization and only when
    the admin consent workflow is enabled.
    """

    @property
    def user_consent_requests(self):
        """A list of pending user consent requests."""
        return self.properties.get(
            "userConsentRequests",
            UserConsentRequestCollection(
                self.context, ResourcePath("userConsentRequests", self.resource_path)
            ),
        )

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: The execution context inherited from Entity base class, typically containing authentication and API connection information for Microsoft Graph API calls

resource_path: The resource path inherited from Entity base class that identifies the location of this consent request in the Microsoft Graph API hierarchy

Return Value

Instantiation returns an AppConsentRequest object that inherits from Entity. The user_consent_requests property returns a UserConsentRequestCollection object containing pending user consent requests associated with this app consent request.

Class Interface

Methods

@property user_consent_requests(self) -> UserConsentRequestCollection property

Purpose: Provides access to the collection of pending user consent requests associated with this app consent request

Returns: A UserConsentRequestCollection object containing all pending user consent requests. If not previously accessed, creates a new collection with the appropriate context and resource path.

Attributes

Name Type Description Scope
properties dict Inherited from Entity base class. Dictionary that stores cached property values, including the user_consent_requests collection after first access instance
context ClientContext Inherited from Entity base class. The execution context containing authentication and API connection information for Microsoft Graph API operations instance
resource_path ResourcePath Inherited from Entity base class. The path identifying this resource's location in the Microsoft Graph API hierarchy instance

Dependencies

  • office365
  • office365.directory.identitygovernance.userconsent.request_collection
  • office365.entity
  • office365.runtime.paths.resource_path

Required Imports

from office365.directory.identitygovernance.userconsent.request_collection import UserConsentRequestCollection
from office365.entity import Entity
from office365.runtime.paths.resource_path import ResourcePath

Usage Example

# Assuming you have a configured context object with Microsoft Graph API authentication
from office365.directory.identitygovernance.appconsent.request import AppConsentRequest
from office365.runtime.paths.resource_path import ResourcePath

# Instantiate an AppConsentRequest (typically done through Graph API client)
app_consent_request = AppConsentRequest(context, resource_path)

# Access the collection of user consent requests
user_requests = app_consent_request.user_consent_requests

# Iterate through pending user consent requests
for user_request in user_requests:
    print(f"User request ID: {user_request.id}")
    print(f"Status: {user_request.status}")

Best Practices

  • This class should typically be instantiated through the Microsoft Graph API client rather than directly, as it requires proper context and resource path initialization
  • The user_consent_requests property uses lazy loading - it creates the collection only when first accessed and caches it in the properties dictionary
  • Ensure the admin consent workflow is enabled in your Microsoft 365 tenant before working with AppConsentRequest objects
  • The class inherits from Entity, so it has access to standard entity operations like get(), update(), and delete() through the base class
  • Always verify that the authenticated user has appropriate permissions to access and manage app consent requests
  • The properties dictionary is used for caching, so subsequent accesses to user_consent_requests will return the same collection instance

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class UserConsentRequest 90.7% similar

    Represents a user consent request for accessing an app or granting permissions when admin authorization is required in an admin consent workflow.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/userconsent/request.py
  • class AppConsentRequestCollection 81.8% similar

    A collection class for managing AppConsentRequest objects, providing methods to query and filter app consent requests within Microsoft Graph API.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/appconsent/request_collection.py
  • class AppConsentApprovalRoute 77.0% similar

    A container class that provides access to app consent request API resources, specifically exposing a collection of app consent requests where admin consent has been requested by users.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/appconsent/approval_route.py
  • class UserConsentRequestCollection 76.2% similar

    A collection class for managing UserConsentRequest entities, providing methods to query, retrieve, and manipulate multiple user consent requests within the Microsoft Graph API context.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/userconsent/request_collection.py
  • class AppRole 60.7% similar

    Represents an application role in Microsoft Graph API that can be assigned to users, groups, or other applications to define permissions and access control.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/applications/roles/role.py
← Back to Browse